-
Notifications
You must be signed in to change notification settings - Fork 753
fix(sagemaker): Improve _handle_call to safely parse JSON, CSV, and byte inputs #2963
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
Conversation
… and byte inputs in Sagemaker tracing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Changes requested ❌
Reviewed everything up to 65f79e7 in 2 minutes and 2 seconds. Click for details.
- Reviewed
45
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/opentelemetry-instrumentation-sagemaker/opentelemetry/instrumentation/sagemaker/__init__.py:164
- Draft comment:
In _handle_call the outputs from _try_parse_json (request_body and response_body) are later passed to json.dumps. If _try_parse_json returns a non-serializable type (like bytes), json.dumps might raise an error. Ensure that the fallback values from _try_parse_json are properly converted to a JSON-serializable format. - Reason this comment was not posted:
Marked as duplicate.
2. packages/opentelemetry-instrumentation-sagemaker/opentelemetry/instrumentation/sagemaker/__init__.py:147
- Draft comment:
The PR title suggests improved handling for CSV inputs as well, but _try_parse_json only attempts JSON parsing. If CSV inputs are expected, consider clarifying the behavior (or adding explicit CSV parsing) to match the PR title and description. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The comment makes assumptions about requirements based on the PR title rather than the code itself. The function is actually well-designed - it tries JSON parsing but gracefully falls back to the raw value if that fails. This means CSV data will pass through unchanged, which is likely the intended behavior. The comment is speculative and asks for clarification rather than pointing out a clear issue. I could be wrong about the requirements - maybe explicit CSV parsing really was intended. The PR title suggesting CSV support provides some evidence for this. Even if CSV parsing was mentioned in the PR title, the code's current behavior of passing through non-JSON data unchanged is a valid approach. Without seeing clear requirements that CSV must be parsed, this comment is too speculative. The comment should be deleted as it's speculative and asks for clarification rather than pointing out a clear code issue. The current code behavior of falling back to raw values is reasonable.
Workflow ID: wflow_dTZhh7VXJkw6mWPA
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
.../opentelemetry-instrumentation-sagemaker/opentelemetry/instrumentation/sagemaker/__init__.py
Outdated
Show resolved
Hide resolved
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM @nirga @galkleinman can u help review and comment? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swa-kn thanks! can we add tests to that?
(also note the failing lint)
Hey @nirga |
feat(instrumentation): ...
orfix(instrumentation): ...
.Important
Improve
_handle_call
in Sagemaker tracing to safely parse JSON, CSV, and byte inputs using_try_parse_json
._handle_call
in__init__.py
to safely parse JSON, CSV, and byte inputs._try_parse_json
to decode JSON from strings or bytes, fallback to raw value on failure._try_parse_json
torequest_body
andresponse_body
in_handle_call
._try_parse_json
to handle JSON decoding with error handling._handle_call
to use_try_parse_json
for input parsing.This description was created by
for 65f79e7. You can customize this summary. It will automatically update as commits are pushed.