RSDK-14517 Reject non-string motion resource names with an explicit TypeError - #1258
Open
viambot wants to merge 3 commits into
Open
RSDK-14517 Reject non-string motion resource names with an explicit TypeError#1258viambot wants to merge 3 commits into
viambot wants to merge 3 commits into
Conversation
MotionClient.move/get_pose and friends take resource names as plain strings. Passing a ResourceName, which older SDK releases accepted, failed inside the protobuf C extension with 'TypeError: bad argument type for built-in operation', naming neither the field nor the expected type. The client now accepts a ResourceName (or any object with a string .name) and uses its name, and raises a TypeError naming the parameter for anything else.
Switches from coercing a ResourceName to rejecting it, per the second option in the ticket: the parameters stay string-only and the client raises a TypeError that names the field and the expected type instead of the protobuf extension's 'bad argument type for built-in operation'.
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.
Problem
MotionClient.moveandMotionClient.get_posetakecomponent_nameas a plain string. Older SDK releases took aResourceName, and that is the form older examples (and agents trained on them) still use. Passing aResourceNametoday fails inside the protobuf C extension with a message that names neither the field nor the expected type:This was observed in 12 of 12 cold agent runs against a Viam machine: every run's first
Move/GetPosecall passed aResourceName, hit that error, and then burned time inspecting the signature before retrying with a string.Change
Per the second option in the Jira item, the parameters stay string-only and the client rejects anything else up front with the error text from the ticket:
Applied to every parameter in the motion client that took a
ResourceNamein older releases, so a copied old call site does not just fail one argument later:move,get_pose,stop_plan,get_plan—component_namemove_on_globe—component_name,movement_sensor_namemove_on_map—component_name,slam_service_nameNo signature, type-hint, or wire-format changes: valid string calls behave exactly as before, and the
Motionabstract interface and service side are untouched.One deliberate deviation from the ticket's wording: the check is an explicit
isinstancetest on the parameter rather than atry/except TypeErroraround the request construction. Catching there would also swallow type errors raised by other fields (for example a baddestination) and mislabel them as a badcomponent_name. The observable behavior for the reported case is identical. Happy to switch to the literal catch if you prefer it.Tests
Added to
tests/test_motion_service.py:moveandget_poseraise the new message when handed aResourceName, andmove_on_globenamesmovement_sensor_namewhen that is the bad argument. Existing tests cover the string path.pytest,ruff check,ruff format, andpyrightpass. (tests/test_native.py,tests/test_rpc.pyandtests/test_spatialmath.pyfail in this sandbox only becauselibviam_rust_utils.socould not be downloaded; unrelated to this change.)Note
Companion TypeScript fix: viamrobotics/viam-typescript-sdk#1001. There the same call is not rejected by protobuf-es at all — a
ResourceNameis serialized as'[object Object]'and sent to the machine as the component name.Key: RSDK-14517
Co-authored by Claude agent for Jira.