serverless-openwhisk icon indicating copy to clipboard operation
serverless-openwhisk copied to clipboard

Openwhisk Returned HTTP 400 (Bad Request) --> "The request content was malformed:

Open michaelwclark opened this issue 4 years ago • 4 comments

If an environment variable or another default parameter is not properly set then sls deploy will throw an error. The error that displays is only: Returned HTTP 400 (Bad Request) --> "The request content was malformed:

However under the covers if you add additional logging you will find.

 message:
   'PUT https://us-south.functions.cloud.ibm.com/api/v1/namespaces/OURNAMESPACE/actions/add-users?overwrite=true Returned HTTP 400 (Bad Request) --> "The request content was malformed:\nparameters malformed!"',
  error:
   { code: '5e5ddc3f2084d2c18cbdbfc66e8665cc',
     error: 'The request content was malformed:\nparameters malformed!' },
  statusCode: 400 }

I feel like there should be a preflight check fo parameters or at the very least a more verbose error message when this happens as it's not 100% apparent what is causing the error without going into the code and adding a log node_modules/serverless-openwhisk/deployFunction/index.js:70

michaelwclark avatar Jul 15 '19 16:07 michaelwclark

Hello Michael - can you expand on what you mean by environment variable or another default parameter not being set? Do you mean the authentication parameters like (__OW_API_HOST) or something else?

Can you provide a test-case for this and it can get added to the backlog? Adding more verbose error messages or pre-flight checks seems like a good idea. If you want to have a go at a PR - I'd happily review and work on getting it merged.

jthomas avatar Jul 16 '19 09:07 jthomas

I have the same error, I just can't figure out what this is about...

Jonarod avatar Sep 12 '19 20:09 Jonarod

Ok got it... I had a typo in my serverless.yml file under the parameters object. Specifically, I had something like:

custom:
  env: ${file(./${self:provider.stage}.env.json)}

functions:
  my_function:
    handler: index.handler
    parameters:
      SECRET_ID: ${self:custom.env.SEGRET_ID}

(note the "G" instead of "C" in self:custom.env.SEGRET_ID)

Jonarod avatar Sep 12 '19 20:09 Jonarod

Where can I find that file when using faas in IBMCloud ?

amitabhprasad avatar Mar 25 '20 17:03 amitabhprasad