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

fix(api): Fix Pydantic error when parsing commands that did not succeed #17264

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

SyntaxColoring
Copy link
Contributor

@SyntaxColoring SyntaxColoring commented Jan 14, 2025

Overview

robot-server sometimes stores, in its database, run commands that do not have a result. For example, if a command failed, it has an error instead of a result.

After the recent Pydantic v1->v2 upgrade, parsing these commands was broken for about 1/3rd of our command types. The server would raise a 500 error. Their Pydantic models were defined like:

result: Optional[FooResult]

In Pydantic v1, that parses JSON where result is null or omitted, but in Pydantic v2, it only parses JSON where result is null. We need to change it to:

result: Optional[FooResult] = None

Addresses RQA-3853, I think.

Test Plan and Hands on Testing

  • Find a GET /runs/.../commands/... request that fails with a 500 error without this PR, and make sure it succeeds with this PR.

Review requests

I made this change by running bump-pydantic on api/src/opentrons/protocol_engine. Double-check my work to make sure no changes snuck in outside of what I've described above.

Risk assessment

Low.

@SyntaxColoring SyntaxColoring changed the title fix(api): Fix Pydantic error when parsing incomplete commands fix(api): Fix Pydantic error when parsing command that did not succeed Jan 14, 2025
@SyntaxColoring SyntaxColoring changed the title fix(api): Fix Pydantic error when parsing command that did not succeed fix(api): Fix Pydantic error when parsing commands that did not succeed Jan 14, 2025
@SyntaxColoring SyntaxColoring changed the base branch from edge to chore_release-8.3.0 January 14, 2025 17:40
@SyntaxColoring SyntaxColoring marked this pull request as ready for review January 14, 2025 17:41
@SyntaxColoring SyntaxColoring requested a review from a team as a code owner January 14, 2025 17:41
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Arrghhhh glad we caught it

@SyntaxColoring SyntaxColoring merged commit 271ad58 into chore_release-8.3.0 Jan 14, 2025
80 of 81 checks passed
@SyntaxColoring SyntaxColoring deleted the command_result_default branch January 14, 2025 22:05
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