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

Handling condition where Entity.cause is not a dict. #267

Merged
merged 6 commits into from
Jan 14, 2021

Conversation

srprash
Copy link
Contributor

@srprash srprash commented Jan 13, 2021

Issue #154

Description of changes:
In a case of exception chaining where an unhandled exception is captured in a subsegment and then propagated to the parent segment/subsegment, the cause property of this parent entity becomes a str from dict to record the exception id from the child subsegment. Any further dictionary operation this cause will result in TypeError.
Doing a type check on the Entity.cause when adding a new exception and resetting the cause to dict since we cannot recover the original cause dict once it has been updated to a string.

Also, making sure when adding multiple exceptions to an entity, they should be appended and not replaced.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@willarmiros willarmiros 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!

tests/test_trace_entities.py Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Jan 13, 2021

Codecov Report

Merging #267 (58082a9) into master (b54ee22) will decrease coverage by 34.95%.
The diff coverage is 50.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #267       +/-   ##
===========================================
- Coverage   79.37%   44.42%   -34.96%     
===========================================
  Files          82       82               
  Lines        3248     3253        +5     
===========================================
- Hits         2578     1445     -1133     
- Misses        670     1808     +1138     
Impacted Files Coverage Δ
aws_xray_sdk/core/models/entity.py 62.41% <50.00%> (-29.95%) ⬇️
aws_xray_sdk/ext/pg8000/patch.py 0.00% <0.00%> (-100.00%) ⬇️
aws_xray_sdk/ext/psycopg2/patch.py 0.00% <0.00%> (-100.00%) ⬇️
aws_xray_sdk/ext/requests/patch.py 0.00% <0.00%> (-100.00%) ⬇️
aws_xray_sdk/ext/pg8000/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
aws_xray_sdk/ext/httplib/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
aws_xray_sdk/ext/pymysql/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
aws_xray_sdk/ext/sqlalchemy/query.py 0.00% <0.00%> (-100.00%) ⬇️
aws_xray_sdk/ext/botocore/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
aws_xray_sdk/ext/psycopg2/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
... and 55 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b54ee22...58082a9. Read the comment docs.

@srprash srprash merged commit 5af2357 into aws:master Jan 14, 2021
Hargrav3s pushed a commit to Gavant/aws-xray-sdk-python that referenced this pull request Mar 22, 2022
* Handling condition where cause is not a dict. Exceptions should be appended not replaced.

* Adding more test cases

* Minor fixes to some tests

* Some type checking in python2 may require to import unicode literals

* Checking python version for type comparison
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.

3 participants