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(robot-server): add default to robot serial #13802

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

sfoster1
Copy link
Member

@sfoster1 sfoster1 commented Oct 17, 2023

Some combination of pydantic and fastapi (fastapi, I'm pretty sure, due to things like pydantic/pydantic#1223 ) conflate "null" and "not present" in weird ways. This means that in the health response pydantic class,

  • If you create robot_serial in the proper way to have a pydantic field that can be either a string or null but must always be passed in to the constructor - annotation Optional[str] and do not provide a default - then pydantic will say there's a field missing if you explicitly pass in null (the bug this fixes, since this 500s the route)
  • If you create robot_serial with a default value, which is not correct because there is no default, then something (probably fastapi) will remove the key from the model rather than issueing it with a null, which is terrible, but is better than the other way I guess.

Updating fastapi might help with this maybe. I don't know.

This changes the semantics of this field to "present and not-null or not present" rather than "always present and maybe null"; luckily, the app side of this will be fine without changes because it was written to handle older health responses that wouldn't have the field.

testing

  • put this on a flex that does not have a serial number in its eeprom or in /var/serial and check that GET /health still works and now does not have a robot_serial field
  • put this on a flex that does have an eeprom serial and check that it works
  • put this on an ot2 that has a serial and check that it works
  • put this on an ot2 that doesn't have a serial and check that it works
    where "works" means "doesn't 500"

Some combination of pydantic and fastapi (fastapi, I'm pretty sure, due
to things like pydantic/pydantic#1223 )
conflate "null" and "not present" in weird ways. This means that in the
health response pydantic class,
- If you create robot_serial in the proper way to have a pydantic field
that can be either a string or null but must always be passed in to the
constructor - annotation Optional[str] and do not provide a default -
then pydantic will say there's a field missing if you explicitly pass
in null (the bug this fixes, since this 500s the route)
- If you create robot_serial with a default value, which is _not
correct_ because there is no default, then something (probably fastapi)
will remove the _key_ from the model rather than issueing it with a
null, which is terrible, but is better than the other way I guess.

Updating fastapi might help with this maybe. I don't know.
@sfoster1 sfoster1 requested a review from a team as a code owner October 17, 2023 16:00
...,
description="The robot serial number. Should be used if not none; if none, use result of /server/update/health.",
default=None,
description="The robot serial number. Should be used if not present; if not present, use result of /server/update/health.",
Copy link
Member

Choose a reason for hiding this comment

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

this should be Should be used if present right?

Copy link
Member

@shlokamin shlokamin left a comment

Choose a reason for hiding this comment

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

tested on flexy which has a serial number on the eeprom

@sfoster1 sfoster1 merged commit 295908b into chore_release-7.0.1 Oct 17, 2023
@sfoster1 sfoster1 deleted the fix-null-serials branch October 17, 2023 17:00
y3rsh added a commit that referenced this pull request Oct 25, 2023
* edge: (77 commits)
  fix(app): update move gantry text in change pipette flow (#13712)
  fix(app): fix CI after release merge back (#13816)
  chore(hardware): add opentrons hardware package to ot 2 build (#13770)
  feat(protocol-designer): correct step count in create file wizard (#13807)
  feat(protocol-designer): error handling in create file wizard (#13804)
  fix(app): invalidate OT2 calibration queries when calibration flows complete (#13809)
  always jog (#13806)
  chore(app): point updates at dns not s3 (#13798)
  docs(api): updated Flex default flow rates (#13796)
  fix(api): Flag pipette as not ready to aspirate after pushing out air (#13728)
  fix(api, hardware): allow OT3Controller to disable tip motors (#13805)
  more blank trials; longer scale stabilize wait; submerge 2.5mm (#13788)
  fix(app): unload adapters after checking position of labware on adapter on heater shaker module (#13803)
  feat(app): wire up location conflict modal for ODD (#13797)
  feat(app): add Deck configuration page component (#13784)
  fix(robot-server): add default to robot serial (#13802)
  feat(protocol-designer, components): prep work for deck config in PD (#13775)
  feat(app, protocol-designer): plug in waste chute asset (#13800)
  fix(app): do not check mag block in calibration status (#13799)
  feat(protocol-designer): edit additional items staging area support (#13752)
  ...
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