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

Minor: print more detailed Lambda errors. #2371

Merged
merged 2 commits into from
Aug 9, 2023
Merged

Minor: print more detailed Lambda errors. #2371

merged 2 commits into from
Aug 9, 2023

Conversation

concretevitamin
Copy link
Member

Users have reported seeing this exception being triggered without much info.

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Any manual or new tests for this PR (please specify below)
  • All smoke tests: pytest tests/test_smoke.py
  • Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • Backward compatibility tests: bash tests/backward_comaptibility_tests.sh

Copy link
Collaborator

@cblmemo cblmemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Left some comments 🤔

@@ -86,8 +87,10 @@ def raise_lambda_error(response: requests.Response) -> None:
resp_json = response.json()
code = resp_json.get('error', {}).get('code')
message = resp_json.get('error', {}).get('message')
except (KeyError, json.decoder.JSONDecodeError):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing the KeyError here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dict.get() doesn't throw KeyError?

except json.decoder.JSONDecodeError:
raise LambdaCloudError('Unexpected error. Status '
f'code: {status_code}; response: {response}; '
f'resp_json: {resp_json}')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add response.reason or response.text to indicate which error happened? Since repr of requests.Response is something like <Response [404]> and does not contain a lot of useful information.

Also, why are we printing resp_json in except json.decoder.JSONDecodeError ? IIUC the resp_json must be None?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done.

Copy link
Collaborator

@cblmemo cblmemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me! Thanks 🫡

@cblmemo cblmemo merged commit f20abc2 into master Aug 9, 2023
15 checks passed
@cblmemo cblmemo deleted the lambda-fix branch August 9, 2023 21:47
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 this pull request may close these issues.

2 participants