Skip to content
This repository has been archived by the owner on Sep 30, 2019. It is now read-only.

Python lambda #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

theoribeiro
Copy link

Whenever the result from the sls invoke was large enough, JSON would only parse the last chunk.
Variable "results" was being used instead of "allResults".

You should consider some other way of getting results from sls invoke since if you have the env variable SLS_DEBUG=* the output from sls will include other information. Same thing if you're debugging your Python function with prints, etc...
I'll put in an issue tomorrow for this bug just so you have it on your radar.

@cbaron
Copy link
Contributor

cbaron commented Apr 5, 2019

@theobribeiro -- you bring up a good point. The current implementation is flawed. However, if we use allResults, then we will not be able to parse the output properly either. A more nuanced, or completely different approach is necessary.

@theoribeiro
Copy link
Author

@cbaron - Agreed it doesn't solve the second part of my PR. But even if you don't have any other outputs from sls invoke, using results instead of allResults will truncate the output to just the last chunk of data. allResults is used for all the other invokes (Go and Ruby) and using it solves that specific issue of truncating the result and not being able to parse the json due to a malformed string.

@theoribeiro
Copy link
Author

@cbaron Any updates on this PR? I just wasted 2 hours trying to understand why my query was returning an error just to find out it was related to this same issue. The query was big so the result was truncated, resulting in a malformed JSON.
This is definitely a bug because this function is not using allResults instead of just results.

@cbaron
Copy link
Contributor

cbaron commented May 5, 2019

I haven't thought about this issue since you brought it up.

Thinking we can try using AWS SAM local, or add some logic where we concat the last n results to try and parse valid JSON. For example, first we try the last result to parse. If it fails, we try the last result and the second to last result, if that fails we try the last 3.

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

Successfully merging this pull request may close these issues.

2 participants