Skip to content

Conversation

@joaomarcoscrs
Copy link
Contributor

@joaomarcoscrs joaomarcoscrs commented Dec 1, 2025

Description

Fixes selector extraction in workflow blocks with Union[List[T], Selector(...)] properties. Previously, selectors in mixed lists like ["literal", "$inputs.tag"] were not parsed correctly, causing them to be treated as literal strings instead of being resolved at runtime.

The fix updates the schema parser to detect array types in union variants and set is_list_element=True appropriately, then modifies the selector parser to use runtime type checking. This enables proper selector resolution in blocks like DetectionsConsensus.classes_to_consider and BoundingBoxVisualization.custom_colors. Includes unit and integration tests.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

  • ✅ New unit tests for Union[List, Selector] patterns
  • ✅ Integration tests with real workflow blocks

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

Docs

  • Docs updated? What were the changes:

Note

Improves selector handling for Union[List[...], Selector(...)] properties.

  • Schema parsing: propagate is_dict_element into union branches and merge is_list_element/is_dict_element across variants when building SelectorDefinition.
  • Selector parsing: use runtime type checks to decide list/dict vs simple selector extraction, preventing selector-like strings in List[str] from being parsed as selectors.
  • Tests: add unit tests for schema/selectors parsers and integration tests validating selector-to-list, literal list, and type-mismatch scenarios in real workflows.

Written by Cursor Bugbot for commit 493ef1a. This will update automatically on new commits. Configure here.

…ctor(...)] patterns. Added checks for array and dict types in schema parser, and updated selectors parser to handle runtime type checks. Included regression tests to ensure correct behavior for mixed lists and selector definitions.
contains_array_type = False
contains_dict_type = False
for type_definition in union_types:
if type_definition.get("type") == "array" and ITEMS_KEY in type_definition:
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use constants for key names

Copy link
Collaborator

Choose a reason for hiding this comment

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

and also values

Copy link
Collaborator

@PawelPeczek-Roboflow PawelPeczek-Roboflow left a comment

Choose a reason for hiding this comment

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

I may not understand something or the tests are simply written to illustrate wrong use-case - almost like it attempts to seek for nested selectors when the type annotation is Union[List[str], Selector(kind=[LIST_OF_VALUES]), when the initial problem was nesting when type is Union[List[Union[str, Selector(kind=[STRING])]], Selector(kind=[LIST_OF_VALUES])

if the code works as if the Union[List[Union[str, Selector(kind=[STRING])]], Selector(kind=[LIST_OF_VALUES]) is provided in situation when Union[List[str], Selector(kind=[LIST_OF_VALUES]) then this is introducing bug

contains_array_type = False
contains_dict_type = False
for type_definition in union_types:
if type_definition.get("type") == "array" and ITEMS_KEY in type_definition:
Copy link
Collaborator

Choose a reason for hiding this comment

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

and also values

@grzegorz-roboflow
Copy link
Collaborator

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!

@codeflash-ai
Copy link
Contributor

codeflash-ai bot commented Jan 12, 2026

⚡️ Codeflash found optimizations for this PR

📄 98% (0.98x) speedup for retrieve_selectors_from_union_definition in inference/core/workflows/execution_engine/introspection/schema_parser.py

⏱️ Runtime : 246 microseconds 125 microseconds (best of 190 runs)

A dependent PR with the suggested changes has been created. Please review:

If you approve, it will be merged into this PR (branch joao/fix-array-input-references).

Static Badge

@PawelPeczek-Roboflow PawelPeczek-Roboflow merged commit 18beb56 into main Jan 12, 2026
50 checks passed
@PawelPeczek-Roboflow PawelPeczek-Roboflow deleted the joao/fix-array-input-references branch January 12, 2026 20:28
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.

6 participants