Skip to content

Valid plan typing of Movable[Any] | Any can have unintended effects due to device lookup being str only #1808

Not planned

Description

@oliwenmandiamond

Description

Taken from #1694 (comment)
"
Value items in mv and mvr can resolve to devices.

Bluesky annotates every positional item in mv and mvr as Movable[Any] | Any. blueapi maps Movable[Any] to a Reference type that looks up a device by name, and keeps that branch first in the union. A string setpoint that matches a registered device name can therefore be replaced by that device object. For example, with a registered movable other, args=["mode", "other"] can send the device other as the setpoint for mode instead of the string "other". Strings that match no device stay literal.

Only device positions should resolve device names. Value positions must keep their literal values. The fix needs a design decision on how to mark device and value positions for these stubs. Choose a mechanism that preserves the string value when it matches a device name.
"

I feel this is more of a blueapi issue. This is a good point, but I think something that could be resolved by if blueapi didn't just use str as a device lookup but instead a serialisable model e.g

{
      "type": "device",
      "name": "my_device", 
} 

Then when using inject in plans it uses

class InjectDevice(BaseModel):

      type = "device"
      
      def __init__(self, name:str):
            self.name=name

And when a client requests for a device (and in future, non device things), it must send the above data rather than just a str which can be confused for a string? This is a more of design issue with blueapi and I am now starting to understand why args kwargs wasn't originally supported. But as I said, I feel the above can be over come with not just using str to identify a server object and should be done in a separate issue. Can someone from core comment on the above to know if that is vaible? ( I know would break things downstream ).

Steps to reproduce

Use bluesky mv plan stub with a registered movable other,.args=["mode", "other"] can send the device other as the setpoint for mode instead of the string "other".

Logs and tracebacks

N/A

blueapi version

1.21.0+

Where are you running blueapi?

Beamline deployment (Kubernetes/Helm)

Impact on operations

Noticeable, workaround exists

Acceptance criteria

  • Blueapi will always correctly look up a device name and cannot be confused by typing annotation

Activity

  1. added
    bug
    needs-triage
    on Nov 24, 2026
  2. shree-iyengar-dls commented on Nov 25, 2026

    @shree-iyengar-dls
    Contributor

    Discussed this in Sprint Review. This issue is a by product of the plan signature so we can't really do anything about it in blueapi without changing the signature.

    The dictionary you mentioned might solve the majority of cases but there's no dictionary that couldn't also technically be a position.

  3. oliwenmandiamond commented on Nov 25, 2026

    @oliwenmandiamond
    ContributorAuthor

    Yes, a dictionary could be a position for a Movable, but we document that a position cannot have this structure as it is reserved for blueapi.

    The more devices that are added to a beamline as it grows and if we also support non device objects as well, the chance of a name clash and genuine attempt to move something to a particular str value (or enum value as this will serialise to a str) will start to increase and trip someone up. A structure is far far less likely to clash with anything.

    I agree this isn't priority right now and will also be a breaking change, but I also think it is something we should try and address down the road so the bug doesn't creep back in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions