Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Error invoking Swift hello world example #194

Open
htmsousa opened this issue Jun 29, 2020 · 1 comment
Open

Error invoking Swift hello world example #194

htmsousa opened this issue Jun 29, 2020 · 1 comment

Comments

@htmsousa
Copy link

htmsousa commented Jun 29, 2020

Hello,

I'm trying to run the Swift hello world example and I'm getting an error:

PS C:\Misc\coding\serverless\openwhisk-swift-simple-http-endpoint> serverless deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Compiling Functions...
Serverless: Compiling Packages...
Serverless: Compiling API Gateway definitions...
Serverless: Compiling Rules...
Serverless: Compiling Triggers & Feeds...
Serverless: Compiling Service Bindings...
Serverless: Deploying Functions...
Serverless: Deploying API Gateway definitions...

  Serverless Error ---------------------------------------

  Failed to deploy API Gateway route due to error: POST https://localhost:31001/api/v1/web/whisk.system/apimgmt/createApi?accesstoken=no_token&spaceguid=23bc46b1-71f6-4ed5-8c54-816aa4f8c502 Returned HTTP 502 (Bad Gateway) --> "API creation failure: Unable to configure the API Gateway (status code 400): {"status":400,"message":"Error: Resource path must begin with '/'."}"

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              12.18.1
     Framework Version:         1.74.1 (standalone)
     Plugin Version:            3.6.14
     SDK Version:               2.3.1
     Components Version:        2.31.6

PS C:\Misc\coding\serverless\openwhisk-swift-simple-http-endpoint>

The error message {"status":400,"message":"Error: Resource path must begin with '/'."}" doesn't help much. I looked into the OpenWhisk logs and I could see the following log in Docker container k8s_user-action_wskowdev-invoker-00-5-prewarm-nodejs10_openwhisk_0a2a529c-34d8-4bac-b999-230ac72b627d_0.
It looks like the request sent while doing serverless deploy.

Swagger JSON object: { basePath: '/',
info:
{ title: 'openwhisk-swift-simple-http-endpoint',
version: '1.0' },
paths: { ping: { get: [Object] } },
swagger: '2.0',
'x-ibm-configuration': { assembly: { execute: [Array] }, cors: { enabled: true } } }
GW URL : undefined
GW URL V2 : http://owdev-apigateway.openwhisk.svc.cluster.local:9000/v2
GW Auth : XXXXXXXXXX
__ow_user : guest
namespace : guest
tenantInstance: undefined / openwhisk
accesstoken : no_token
spaceguid : 23bc46b1-71f6-4ed5-8c54-816aa4f8c502
responsetype : undefined
API name : undefined
basepath : /
relpath : undefined
GW method : undefined
calledAsWebAction: true
apidoc :
{"namespace":"guest","swagger":{"basePath":"/","info":{"title":"openwhisk-swift-simple-http-endpoint","version":"1.0"},"paths":{"ping":{"get":{"operationId":"get-ping","responses":{"200":{"description":"A successful invocation response"}},"x-openwhisk":{"action":"openwhisk-swift-simple-http-endpoint-dev-ping","namespace":"guest","package":"default","url":"https://localhost:31001/api/v1/web/guest/default/openwhisk-swift-simple-http-endpoint-dev-ping.json"}}}},"swagger":"2.0","x-ibm-configuration":{"assembly":{"execute":[{"operation-switch":{"case":[{"execute":[{"set-variable":{"actions":[{"set":"message.headers.X-Require-Whisk-Auth","value":"c7884121763970f4effa21557f0de0bdf4579887e3f0a4638b6d897723642a85da87ca9bf1a3e363e9f3175493e9cff060a1a83a0fa985ba6d3b58f960dd580a"}]}},{"invoke":{"target-url":"https://localhost:31001/api/v1/web/guest/default/openwhisk-swift-simple-http-endpoint-dev-ping.json","verb":"keep"}}],"operations":["get-ping"]}]}}]},"cors":{"enabled":true}}}}
getApis: querying APIs based on basepath
getApis: request: {"followAllRedirects":true,"url":"http://owdev-apigateway.openwhisk.svc.cluster.local:9000/v2/23bc46b1-71f6-4ed5-8c54-816aa4f8c502/apis?limit=undefined&skip=undefined","headers":{"Accept":"application/json","User-Agent":"OpenWhisk-apimgmt/1.0.0 openwhisk-client-js openwhisk-client-js openwhisk-client-js openwhisk-client-js","Authorization":"Bearer no_token"},"json":true,"qs":{"basePath":"/"}}
getApis: response status: 200
getApis: response headers: {"server":"openresty/1.13.6.2","date":"Mon, 29 Jun 2020 21:57:32 GMT","content-type":"application/json; charset=utf-8","transfer-encoding":"chunked","connection":"close","x-request-id":"U8hg2LIxuR8bHep6bSVet9g8DKzmKgzl"}
getApis: body type = object
getApis: response JSON.stringify(body): []
Got 0 APIs
No API found for namespace guest with basePath /
Use provided swagger as the entire API; override any existing API
Validating Swagger doc before sending it to API GW.
validateFinalSwagger: Validating swapper before posting to API GW.
validateFinalSwagger: Validation of swagger before posting to API GW was successful.
Final swagger API config: {"basePath":"/","info":{"title":"openwhisk-swift-simple-http-endpoint","version":"1.0"},"paths":{"ping":{"get":{"operationId":"get-ping","responses":{"200":{"description":"A successful invocation response"}},"x-openwhisk":{"action":"openwhisk-swift-simple-http-endpoint-dev-ping","namespace":"guest","package":"default","url":"https://localhost:31001/api/v1/web/guest/default/openwhisk-swift-simple-http-endpoint-dev-ping.json"}}}},"swagger":"2.0","x-ibm-configuration":{"assembly":{"execute":[{"operation-switch":{"case":[{"execute":[{"set-variable":{"actions":[{"set":"message.headers.X-Require-Whisk-Auth","value":"c7884121763970f4effa21557f0de0bdf4579887e3f0a4638b6d897723642a85da87ca9bf1a3e363e9f3175493e9cff060a1a83a0fa985ba6d3b58f960dd580a"}]}},{"invoke":{"target-url":"https://localhost:31001/api/v1/web/guest/default/openwhisk-swift-simple-http-endpoint-dev-ping.json","verb":"keep"}}],"operations":["get-ping"]}]}}]},"cors":{"enabled":true}}}
addApiToGateway:
addApiToGateway: request: {
"followAllRedirects": true,
"url": "http://owdev-apigateway.openwhisk.svc.cluster.local:9000/v2/23bc46b1-71f6-4ed5-8c54-816aa4f8c502/apis",
"json": {
"basePath": "/",
"info": {
"title": "openwhisk-swift-simple-http-endpoint",
"version": "1.0"
},
"paths": {
"ping": {
"get": {
"operationId": "get-ping",
"responses": {
"200": {
"description": "A successful invocation response"
}
},
"x-openwhisk": {
"action": "openwhisk-swift-simple-http-endpoint-dev-ping",
"namespace": "guest",
"package": "default",
"url": "https://localhost:31001/api/v1/web/guest/default/openwhisk-swift-simple-http-endpoint-dev-ping.json"
}
�
}
}
},
"swagger": "2.0",
"x-ibm-configuration": {
"assembly": {
"execute": [
{
"operation-switch": {
"case": [
{
"execute": [
{
"set-variable": {
"actions": [
{
"set": "message.headers.X-Require-Whisk-Auth",
"value": "c7884121763970f4effa21557f0de0bdf4579887e3f0a4638b6d897723642a85da87ca9bf1a3e363e9f3175493e9cff060a1a83a0fa985ba6d3b58f960dd580a"
}
]
}
},
{
"invoke": {
"target-url": "https://localhost:31001/api/v1/web/guest/default/openwhisk-swift-simple-http-endpoint-dev-ping.json",
"verb": "keep"
}
}
],
"operations": [
"get-ping"
]
}
]
}
}
�
]
},
"cors": {
"enabled": true
}
}
},
"headers": {
"User-Agent": "OpenWhisk-apimgmt/1.0.0 openwhisk-client-js openwhisk-client-js openwhisk-client-js openwhisk-client-js",
"Authorization": "Bearer no_token"
}
}
addApiToGateway: response status:400
addApiToGateway: response headers: {"server":"openresty/1.13.6.2","date":"Mon, 29 Jun 2020 21:57:32 GMT","content-type":"application/json; charset=utf-8","transfer-encoding":"chunked","connection":"close"}
addApiToGateway: response body: {"status":400,"message":"Error: Resource path must begin with '/'."}
makeJsonString: String is not JSON, so need to convert it: SyntaxError: Unexpected token U in JSON at position 0
API creation failure: Unable to configure the API Gateway (status code 400): {"status":400,"message":"Error: Resource path must begin with '/'."}
makeErrorResponseObject: isWebAction: true
makeJsonString: String is not JSON, so need to convert it: SyntaxError: Unexpected token A in JSON at position 0
XXX_THE_END_OF_A_WHISK_ACTIVATION_XXX
XXX_THE_END_OF_A_WHISK_ACTIVATION_XXX

If you look closely there are 2 invalid characters . Copying and pasting the log in notepad++ it is possible to see what is that invalid char:
image

Doing a quick search on Google we can see that SOH is the Ctrl ^A. Could that be the reason for the error Unexpected token A in JSON at position 0? Why is it there? Any idea @jthomas ?

Ctrl |ASCII |Dec |Hex | Meaning
^@   |NUL   |000 |00  | Null character
^A   |SOH   |001 |01  | Start of Header

Execution environment:

  • Windows 10 Pro
  • Docker Desktop for Windows using WSL 2 based engine with Kubernetes
  • Whisk API:
{"api_version":"1.0.0","api_version_path":"v1","build":"2020-06-17-15:21:13Z","buildno":"20200617a","description":"OpenWhisk API","swagger_paths":{"api-docs":"/api-docs","ui":"/docs"}}
whisk API build         2020-06-17-15:21:13Z
whisk API build number  20200617a
@htmsousa
Copy link
Author

Also tested the Node example (https://github.com/serverless/examples/tree/master/openwhisk-node-simple-http-endpoint) just to make sure it wasn't related with Swift and same thing happens.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant