From b5a68facb620ebc90ae62ace26cb598db5df91d0 Mon Sep 17 00:00:00 2001 From: Rafel Bennasar Crespi <253519461+rafel-roboflow@users.noreply.github.com> Date: Tue, 21 Apr 2026 12:15:50 +0200 Subject: [PATCH] changes for treating color as with rgb_color instead of string --- .../v1/dynamic_blocks/block_assembler.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/inference/core/workflows/execution_engine/v1/dynamic_blocks/block_assembler.py b/inference/core/workflows/execution_engine/v1/dynamic_blocks/block_assembler.py index 816b7204e1..e6b47d9f60 100644 --- a/inference/core/workflows/execution_engine/v1/dynamic_blocks/block_assembler.py +++ b/inference/core/workflows/execution_engine/v1/dynamic_blocks/block_assembler.py @@ -221,6 +221,13 @@ def build_input( return input_type, field_metadata +# Kinds whose values are serialized as strings on the wire. When one of these kinds +# is declared on the selector side of a dynamic input, `str` is auto-added to the +# accepted value types so literals like "BLACK" or "#FF0000" are accepted — mirroring +# how core blocks like text_display declare `Union[str, Selector(kind=[STRING_KIND])]`. +_STRING_LITERAL_KINDS = {"rgb_color"} + + def build_input_field_type( block_type: str, input_name: str, @@ -238,6 +245,11 @@ def build_input_field_type( input_name=input_name, input_definition=input_definition, ) + if ( + _declares_string_literal_kind(input_definition) + and str not in input_type_union_elements + ): + input_type_union_elements.append(str) if not input_type_union_elements: raise DynamicBlockError( public_message=f"There is no definition of input type found for property: {input_name} of " @@ -253,6 +265,13 @@ def build_input_field_type( return input_type +def _declares_string_literal_kind(input_definition: DynamicInputDefinition) -> bool: + for kinds in input_definition.selector_data_kind.values(): + if any(kind in _STRING_LITERAL_KINDS for kind in kinds): + return True + return False + + def collect_python_types_for_selectors( block_type: str, input_name: str,