{"action":"created","comment":{"url":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/comments/200493379","pull_request_review_id":134822482,"id":200493379,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDQ5MzM3OQ==","diff_hunk":"@@ -118,4 +121,19 @@ def get_lambda_output(stdout_stream):\n             # Last line is Lambda response. Make sure to strip() so we get rid of extra whitespaces & newlines around\n             lambda_response = stdout_data[last_line_position:].strip()\n \n-        return lambda_response, lambda_logs\n+        is_lambda_user_error_response = False\n+\n+        try:\n+            lambda_response_dict = json.loads(lambda_response)\n+\n+            if isinstance(lambda_response_dict, dict) and \\\n+                    len(lambda_response_dict.keys()) == 3 and \\","path":"samcli/local/services/base_local_service.py","position":27,"original_position":27,"commit_id":"503119dd225be22b74cb116b038945230d223b37","original_commit_id":"503119dd225be22b74cb116b038945230d223b37","user":{"login":"jfuss","id":32497805,"node_id":"MDQ6VXNlcjMyNDk3ODA1","avatar_url":"https://avatars2.githubusercontent.com/u/32497805?v=4","gravatar_id":"","url":"https://api.github.com/users/jfuss","html_url":"https://github.com/jfuss","followers_url":"https://api.github.com/users/jfuss/followers","following_url":"https://api.github.com/users/jfuss/following{/other_user}","gists_url":"https://api.github.com/users/jfuss/gists{/gist_id}","starred_url":"https://api.github.com/users/jfuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfuss/subscriptions","organizations_url":"https://api.github.com/users/jfuss/orgs","repos_url":"https://api.github.com/users/jfuss/repos","events_url":"https://api.github.com/users/jfuss/events{/privacy}","received_events_url":"https://api.github.com/users/jfuss/received_events","type":"User","site_admin":false},"body":"duh... :) will update","created_at":"2018-07-05T21:21:17Z","updated_at":"2018-07-05T21:21:18Z","html_url":"https://github.com/awslabs/aws-sam-cli/pull/532#discussion_r200493379","pull_request_url":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/532","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/comments/200493379"},"html":{"href":"https://github.com/awslabs/aws-sam-cli/pull/532#discussion_r200493379"},"pull_request":{"href":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/532"}},"in_reply_to_id":200472772},"pull_request":{"url":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/532","id":199495677,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk5NDk1Njc3","html_url":"https://github.com/awslabs/aws-sam-cli/pull/532","diff_url":"https://github.com/awslabs/aws-sam-cli/pull/532.diff","patch_url":"https://github.com/awslabs/aws-sam-cli/pull/532.patch","issue_url":"https://api.github.com/repos/awslabs/aws-sam-cli/issues/532","number":532,"state":"open","locked":false,"title":"[WIP] feat(LocalLambdaService): Error handling for local lambda","user":{"login":"jfuss","id":32497805,"node_id":"MDQ6VXNlcjMyNDk3ODA1","avatar_url":"https://avatars2.githubusercontent.com/u/32497805?v=4","gravatar_id":"","url":"https://api.github.com/users/jfuss","html_url":"https://github.com/jfuss","followers_url":"https://api.github.com/users/jfuss/followers","following_url":"https://api.github.com/users/jfuss/following{/other_user}","gists_url":"https://api.github.com/users/jfuss/gists{/gist_id}","starred_url":"https://api.github.com/users/jfuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfuss/subscriptions","organizations_url":"https://api.github.com/users/jfuss/orgs","repos_url":"https://api.github.com/users/jfuss/repos","events_url":"https://api.github.com/users/jfuss/events{/privacy}","received_events_url":"https://api.github.com/users/jfuss/received_events","type":"User","site_admin":false},"body":"Details:\r\n* Handling for when lambda returns an error\r\n* Handled payload could not be parsed as JSON\r\n* Abstracted if the lambda output is an error from the container into LambdaOutputParser\r\n* Added handling for X-Amz-Log-Type\r\n* Added handling for X-Amz-Invocation-Type\r\n* Moved all Request validate to flask.before_request call\r\n* Added handling for Query parameters (not supported)\r\n* Added handling for unsupported_media_type\r\n* Added handling for ServiceError\r\n* Added handling for generic 404 Error handling\r\n* Fix up tests to make them runable\r\n\r\n*Description of changes:*\r\nThis is to handle the Error cases that can occur in the Local Lambda Service. This is meant to mimic the actually service with some caveats that are specific to local:\r\n* The generic 404 has the same response if the Lambda Function does not exits but with an empty string for the function. This is due to the generic 404 being for any endpoint that does not exist. We handle the functions not found if it follows the endpoint schema we setup. I am considering moving this to, be something along the lines of 'this endpoint does not exist' but haven't landed or changed this yet.\r\n* Any Service error will be a 'generic' 500 error.\r\n* Currently, we only supported X-Amz-Log-Type = 'None' and X-Amz-Invocation-Type = 'RequestResponse'\r\n* The arn of the function given in the ResourceNotFound 404 is hardcoded with an account id and region: us-west-2. The region is passed to the service through a 'context' in the request: `context': {'auth_type': None, 'client_region': u'us-west-2',` but Flask seems to swallow this part of the request and have not found a way to get at this information.\r\n\r\n*Work In Progress*\r\nFollowing items are remaining:\r\n- [ ] Add Functional Tests for each Error case handled.\r\n- [ ] Add Unit tests\r\n- [ ] validate error cases match the Lambda Service (note: some will be different and specific to local only)\r\n- [ ] Test the LocalLambdaInvoke by using the AWS CLI to call\r\n- [ ] Some general code cleanup\r\n\r\nBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.\r\n","created_at":"2018-07-05T14:49:23Z","updated_at":"2018-07-05T21:21:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc804d1b0d46db9bd016e19f533fd7852950cdbb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/532/commits","review_comments_url":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/532/comments","review_comment_url":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/comments{/number}","comments_url":"https://api.github.com/repos/awslabs/aws-sam-cli/issues/532/comments","statuses_url":"https://api.github.com/repos/awslabs/aws-sam-cli/statuses/503119dd225be22b74cb116b038945230d223b37","head":{"label":"jfuss:lls-error-handling","ref":"lls-error-handling","sha":"503119dd225be22b74cb116b038945230d223b37","user":{"login":"jfuss","id":32497805,"node_id":"MDQ6VXNlcjMyNDk3ODA1","avatar_url":"https://avatars2.githubusercontent.com/u/32497805?v=4","gravatar_id":"","url":"https://api.github.com/users/jfuss","html_url":"https://github.com/jfuss","followers_url":"https://api.github.com/users/jfuss/followers","following_url":"https://api.github.com/users/jfuss/following{/other_user}","gists_url":"https://api.github.com/users/jfuss/gists{/gist_id}","starred_url":"https://api.github.com/users/jfuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfuss/subscriptions","organizations_url":"https://api.github.com/users/jfuss/orgs","repos_url":"https://api.github.com/users/jfuss/repos","events_url":"https://api.github.com/users/jfuss/events{/privacy}","received_events_url":"https://api.github.com/users/jfuss/received_events","type":"User","site_admin":false},"repo":{"id":132761763,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI3NjE3NjM=","name":"aws-sam-cli","full_name":"jfuss/aws-sam-cli","owner":{"login":"jfuss","id":32497805,"node_id":"MDQ6VXNlcjMyNDk3ODA1","avatar_url":"https://avatars2.githubusercontent.com/u/32497805?v=4","gravatar_id":"","url":"https://api.github.com/users/jfuss","html_url":"https://github.com/jfuss","followers_url":"https://api.github.com/users/jfuss/followers","following_url":"https://api.github.com/users/jfuss/following{/other_user}","gists_url":"https://api.github.com/users/jfuss/gists{/gist_id}","starred_url":"https://api.github.com/users/jfuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfuss/subscriptions","organizations_url":"https://api.github.com/users/jfuss/orgs","repos_url":"https://api.github.com/users/jfuss/repos","events_url":"https://api.github.com/users/jfuss/events{/privacy}","received_events_url":"https://api.github.com/users/jfuss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jfuss/aws-sam-cli","description":"AWS SAM CLI 🐿 is a CLI tool for local development and testing of Serverless applications","fork":true,"url":"https://api.github.com/repos/jfuss/aws-sam-cli","forks_url":"https://api.github.com/repos/jfuss/aws-sam-cli/forks","keys_url":"https://api.github.com/repos/jfuss/aws-sam-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jfuss/aws-sam-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jfuss/aws-sam-cli/teams","hooks_url":"https://api.github.com/repos/jfuss/aws-sam-cli/hooks","issue_events_url":"https://api.github.com/repos/jfuss/aws-sam-cli/issues/events{/number}","events_url":"https://api.github.com/repos/jfuss/aws-sam-cli/events","assignees_url":"https://api.github.com/repos/jfuss/aws-sam-cli/assignees{/user}","branches_url":"https://api.github.com/repos/jfuss/aws-sam-cli/branches{/branch}","tags_url":"https://api.github.com/repos/jfuss/aws-sam-cli/tags","blobs_url":"https://api.github.com/repos/jfuss/aws-sam-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jfuss/aws-sam-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jfuss/aws-sam-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/jfuss/aws-sam-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jfuss/aws-sam-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/jfuss/aws-sam-cli/languages","stargazers_url":"https://api.github.com/repos/jfuss/aws-sam-cli/stargazers","contributors_url":"https://api.github.com/repos/jfuss/aws-sam-cli/contributors","subscribers_url":"https://api.github.com/repos/jfuss/aws-sam-cli/subscribers","subscription_url":"https://api.github.com/repos/jfuss/aws-sam-cli/subscription","commits_url":"https://api.github.com/repos/jfuss/aws-sam-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/jfuss/aws-sam-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/jfuss/aws-sam-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/jfuss/aws-sam-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/jfuss/aws-sam-cli/contents/{+path}","compare_url":"https://api.github.com/repos/jfuss/aws-sam-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jfuss/aws-sam-cli/merges","archive_url":"https://api.github.com/repos/jfuss/aws-sam-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jfuss/aws-sam-cli/downloads","issues_url":"https://api.github.com/repos/jfuss/aws-sam-cli/issues{/number}","pulls_url":"https://api.github.com/repos/jfuss/aws-sam-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/jfuss/aws-sam-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/jfuss/aws-sam-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jfuss/aws-sam-cli/labels{/name}","releases_url":"https://api.github.com/repos/jfuss/aws-sam-cli/releases{/id}","deployments_url":"https://api.github.com/repos/jfuss/aws-sam-cli/deployments","created_at":"2018-05-09T13:34:41Z","updated_at":"2018-06-18T19:12:16Z","pushed_at":"2018-07-05T14:40:14Z","git_url":"git://github.com/jfuss/aws-sam-cli.git","ssh_url":"git@github.com:jfuss/aws-sam-cli.git","clone_url":"https://github.com/jfuss/aws-sam-cli.git","svn_url":"https://github.com/jfuss/aws-sam-cli","homepage":"","size":16977,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"awslabs:develop","ref":"develop","sha":"bd09c29cbdf10fd15e45653966774dc05cb5e189","user":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":92205085,"node_id":"MDEwOlJlcG9zaXRvcnk5MjIwNTA4NQ==","name":"aws-sam-cli","full_name":"awslabs/aws-sam-cli","owner":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/awslabs/aws-sam-cli","description":"AWS SAM CLI 🐿 is a CLI tool for local development and testing of Serverless applications","fork":false,"url":"https://api.github.com/repos/awslabs/aws-sam-cli","forks_url":"https://api.github.com/repos/awslabs/aws-sam-cli/forks","keys_url":"https://api.github.com/repos/awslabs/aws-sam-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awslabs/aws-sam-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awslabs/aws-sam-cli/teams","hooks_url":"https://api.github.com/repos/awslabs/aws-sam-cli/hooks","issue_events_url":"https://api.github.com/repos/awslabs/aws-sam-cli/issues/events{/number}","events_url":"https://api.github.com/repos/awslabs/aws-sam-cli/events","assignees_url":"https://api.github.com/repos/awslabs/aws-sam-cli/assignees{/user}","branches_url":"https://api.github.com/repos/awslabs/aws-sam-cli/branches{/branch}","tags_url":"https://api.github.com/repos/awslabs/aws-sam-cli/tags","blobs_url":"https://api.github.com/repos/awslabs/aws-sam-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awslabs/aws-sam-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awslabs/aws-sam-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/awslabs/aws-sam-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awslabs/aws-sam-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/awslabs/aws-sam-cli/languages","stargazers_url":"https://api.github.com/repos/awslabs/aws-sam-cli/stargazers","contributors_url":"https://api.github.com/repos/awslabs/aws-sam-cli/contributors","subscribers_url":"https://api.github.com/repos/awslabs/aws-sam-cli/subscribers","subscription_url":"https://api.github.com/repos/awslabs/aws-sam-cli/subscription","commits_url":"https://api.github.com/repos/awslabs/aws-sam-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/awslabs/aws-sam-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/awslabs/aws-sam-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/awslabs/aws-sam-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/awslabs/aws-sam-cli/contents/{+path}","compare_url":"https://api.github.com/repos/awslabs/aws-sam-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awslabs/aws-sam-cli/merges","archive_url":"https://api.github.com/repos/awslabs/aws-sam-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awslabs/aws-sam-cli/downloads","issues_url":"https://api.github.com/repos/awslabs/aws-sam-cli/issues{/number}","pulls_url":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/awslabs/aws-sam-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/awslabs/aws-sam-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awslabs/aws-sam-cli/labels{/name}","releases_url":"https://api.github.com/repos/awslabs/aws-sam-cli/releases{/id}","deployments_url":"https://api.github.com/repos/awslabs/aws-sam-cli/deployments","created_at":"2017-05-23T18:16:23Z","updated_at":"2018-07-05T19:58:34Z","pushed_at":"2018-07-05T20:24:19Z","git_url":"git://github.com/awslabs/aws-sam-cli.git","ssh_url":"git@github.com:awslabs/aws-sam-cli.git","clone_url":"https://github.com/awslabs/aws-sam-cli.git","svn_url":"https://github.com/awslabs/aws-sam-cli","homepage":"","size":16920,"stargazers_count":2728,"watchers_count":2728,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":312,"mirror_url":null,"archived":false,"open_issues_count":88,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":312,"open_issues":88,"watchers":2728,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/532"},"html":{"href":"https://github.com/awslabs/aws-sam-cli/pull/532"},"issue":{"href":"https://api.github.com/repos/awslabs/aws-sam-cli/issues/532"},"comments":{"href":"https://api.github.com/repos/awslabs/aws-sam-cli/issues/532/comments"},"review_comments":{"href":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/532/comments"},"review_comment":{"href":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/awslabs/aws-sam-cli/pulls/532/commits"},"statuses":{"href":"https://api.github.com/repos/awslabs/aws-sam-cli/statuses/503119dd225be22b74cb116b038945230d223b37"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"jfuss"}}