Merged
Conversation
Comment on lines
+34
to
44
|
|
||
| return response_200 | ||
|
|
||
| if response.status_code == 404: | ||
| response_404 = ErrorResponse.from_dict(response.json()) | ||
|
|
||
| return response_404 | ||
|
|
||
| if response.status_code == 409: | ||
| response_409 = ErrorResponse.from_dict(response.json()) | ||
|
|
||
| return response_409 | ||
|
|
||
| if response.status_code == 422: | ||
| response_422 = HTTPValidationError.from_dict(response.json()) | ||
|
|
There was a problem hiding this comment.
Bug: The cancel_task endpoint no longer handles the 409 status code for already-completed tasks. This causes an unhandled UnexpectedStatus exception, contradicting the docstring and crashing calling code.
Severity: CRITICAL
Suggested Fix
Reinstate the handling for the 409 status code in the _parse_response function for the cancel_task endpoint. This will ensure that when a 409 is returned, it is parsed into a proper response object instead of raising an UnexpectedStatus exception, aligning the behavior with the documentation.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location:
src/everyrow/generated/api/tasks/cancel_task_tasks_task_id_cancel_post.py#L28-L44
Potential issue: The removal of the `409` status code handling in the `_parse_response`
function for the `cancel_task` endpoint will cause an unhandled exception. When a user
attempts to cancel a task that has already completed, the API returns a `409` status.
Because this status is no longer handled, the code falls through to
`client.raise_on_unexpected_status`, which raises an `errors.UnexpectedStatus`
exception. The calling function, `cancel_task()` in `task.py`, does not catch this
exception, causing it to propagate and crash the user's application. This contradicts
the function's docstring, which explicitly states that a `409` is a valid return status.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
I think it's been a while since anyone did this. There are a lot of changes to bring in.