Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lambda integration: all responses are empty due to default template file containing newline. #284

Closed
bebbi opened this issue Aug 10, 2017 · 3 comments

Comments

@bebbi
Copy link
Contributor

bebbi commented Aug 10, 2017

I'm using lambda integration.

My responses are all newlines only instead of the lambda response data.

I've tracked this down to this projects offline-default.res.vm file to contain only a newline.

I'd be happy to PR the correct default template into this file, but I don't know where to source it.

@bebbi
Copy link
Contributor Author

bebbi commented Aug 10, 2017

OK some more info here. The manual_test helloLambdaIntegration funcs work due to a bug in the implementation.

If we go through the example, and call the above func:
In this line

const responseTemplate = responseTemplates[responseContentType];

responseTemplates is

{
  application/json;charset=UTF-8: ""
}

And responseContentType is application/json, so in that line, no match returns undefined.

Which fails the test in

if (responseTemplate) {

Whereas in my case, I defined the response headers application/json in serverless.yml, and perhaps because of this, the default template (newline) got associated and responseTemplate looks like this:

{
  application/json;charset=UTF-8: ""
  application/json: "\n"
}

which passes the above test, triggers template mapping and then fails to return data because the newline is not a valid template.

I'm going to submit the quick fix of removing the newline from the default mapping. I will also add a newline check for the template check above because the newline in the template file could easily be re-introduced via some linter (probably was in the first place). But it would be good to check the general implementation as well aside from those fixes.

@bebbi bebbi changed the title lambda integration: all responses are empty due to default template file empty. lambda integration: all responses are empty due to default template file containing newline. Aug 10, 2017
@dherault
Copy link
Owner

dherault commented Sep 5, 2017

Hi, I'm back from holidays. Thank you for your patience. I'll review all the issues and PRs in the upcoming days and will ship asap.

@dherault
Copy link
Owner

dherault commented Sep 5, 2017

Thanks @bebbi !

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

Successfully merging a pull request may close this issue.

2 participants