Conversation
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to 42801ce in 1 minute and 27 seconds. Click for details.
- Reviewed
141lines of code in3files - Skipped
0files when reviewing. - Skipped posting
3draft 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. instructor/processing/function_calls.py:95
- Draft comment:
Re-raising the original JSONDecodeError (instead of wrapping it in ValueError) ensures it gets caught by the retry mechanism. Consider adding an inline comment referencing issue #1856 so future maintainers understand why this change was made. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 80% vs. threshold = 85% The comment makes a good point about documenting the rationale behind error handling changes. The change from wrapping to re-raising appears intentional and tied to retry behavior. Without documentation, future maintainers may not understand why this specific error handling approach was chosen and revert it. The comment assumes issue #1856 exists and is relevant, but we don't have access to verify that. The retry mechanism mentioned isn't visible in the code shown. Even without seeing issue #1856, documenting error handling decisions is a good practice, especially when changing from a more explicit approach (wrapping in ValueError) to a less explicit one (re-raising). Keep the comment as it promotes good documentation practices for error handling changes that may not be immediately obvious to future maintainers.
2. tests/test_retry_json_mode.py:23
- Draft comment:
The new regression tests correctly simulate retry behavior for both JSONDecodeError (in non-strict mode) and ValidationError (in strict mode). This effectively ensures that the retry handler processes these errors as intended. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =0%<= threshold85%This comment is purely informative and does not provide any actionable feedback or suggestions for improvement. It simply praises the existing tests without suggesting any changes or identifying any issues.
3. tests/test_retry_json_mode.py:28
- Draft comment:
Typo: In the docstring, "handle_reask_kwargs" appears to be a misspelling. Did you mean "handle_retry_kwargs"? - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 80% vs. threshold = 85% The comment is about a real change in the diff since this is a new file. The suggestion seems reasonable as 'reask' vs 'retry' is inconsistent with the terminology used elsewhere in the file. However, without access to the actual codebase, I can't be 100% certain that 'handle_reask_kwargs' isn't a real function name somewhere. I don't have access to the full codebase to verify if 'handle_reask_kwargs' might be a valid function name in some other file. The comment could be wrong if this is actually the correct function name. While I can't be 100% certain, the consistent use of 'retry' throughout this file and the test name itself strongly suggests this is indeed a typo that should be fixed for clarity and consistency. Keep the comment as it appears to identify a genuine inconsistency in terminology that should be fixed for better code clarity and maintenance.
Workflow ID: wflow_mIBQoYgdlW1x5SVX
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
instructor | b4bc8a5 | Commit Preview URL Branch Preview URL |
Oct 27 2025, 07:05 PM |
Contributor
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed dd09136 in 28 seconds. Click for details.
- Reviewed
13lines of code in1files - Skipped
0files when reviewing. - Skipped posting
1draft 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. tests/test_retry_json_mode.py:10
- Draft comment:
Good cleanup: the unused 'patch' import was removed. This adheres to DRY principles; ensure that no test is relying on it. - Reason this comment was not posted:
Confidence changes required:0%<= threshold85%None
Workflow ID: wflow_imGJV6cqVDN0pOdw
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
…tches it; add regression tests for JSON/Validation errors in retry (closes #1856) Co-Authored-By: Jason Liu <[email protected]>
Co-Authored-By: Jason Liu <[email protected]>
dd09136 to
b4bc8a5
Compare
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(processing): ensure JSON decode errors are caught by retry handler (#1856)
Summary
Fixed a bug where
JSONDecodeErrorin JSON mode was being wrapped inValueError, causing it to bypass the retry mechanism's validation error handler. This preventedhandle_reask_kwargsfrom being called, so retries didn't receive error feedback to improve subsequent attempts.Root cause: In
_validate_model_from_json, line 95 was wrappingJSONDecodeErrorinValueError. The retry handler only catchesValidationError,JSONDecodeError, andInstructorValidationErrorexplicitly, so the wrapped error fell through to the genericExceptionhandler.Fix: Changed line 95 from
raise ValueError(f"Failed to parse JSON: {e}") from eto justraise, allowingJSONDecodeErrorto propagate directly to the retry handler.Changes:
instructor/processing/function_calls.py: Removed ValueError wrapping (1 line change)tests/test_json_extraction.py: Fixed existing test + added test for non-strict modetests/test_retry_json_mode.py: New regression tests for JSON/validation error retry behaviorReview & Testing Checklist for Human
max_retries > 0. Verify that:handle_reask_kwargsis called between attemptsValueErrorbeing raised from_validate_model_from_json. Search codebase for catches ofValueErrorthat might be affected.Test Plan Recommendation
Notes
Session: Requested by Jason Liu (@jxnl) - https://app.devin.ai/sessions/9184a01bca9d4e7e97e3aade131cf0ea
Important
Fixes JSON decode error handling in retry mechanism by removing
ValueErrorwrapping infunction_calls.pyand adds regression tests._validate_model_from_jsoninfunction_calls.pyby removingValueErrorwrapping forJSONDecodeError, allowing it to be caught by the retry handler.handle_reask_kwargsis called for retries, providing error feedback for subsequent attempts.test_json_extraction.pyto include tests for JSON decode errors in strict and non-strict modes.test_retry_json_mode.pywith regression tests to verify retry behavior forJSONDecodeErrorandValidationError.function_calls.pyto improve error visibility.This description was created by
for dd09136. You can customize this summary. It will automatically update as commits are pushed.