Skip to content

Typed Int search attributes encode boolean values as Int payloads #2173

Not planned

Description

@raunakpandey1

What happened

The typed search attribute encoder accepts True or False for an Int key. It then labels the payload Int while writing true or false to the JSON body. Temporal defines Bool and Int as distinct search attribute types. This lets a wrong value through the SDK's type validation when a workflow attribute is populated from user input or a loosely typed mapping.

from temporalio.common import SearchAttributeKey
from temporalio.converter._search_attributes import encode_typed_search_attribute_value

payload = encode_typed_search_attribute_value(SearchAttributeKey.for_int("ItemCount"), True)
print(payload.metadata["type"], payload.data)  # b'Int' b'true'

Expected: raise TypeError for a Boolean passed to an Int key, as for other mismatched types. Actual: Python's isinstance(True, int) succeeds and the payload is sent with inconsistent type and value.

Reproduced against the source converter at ce8cd48 on Python 3.13/macOS with the released 1.37.0 SDK as the test runtime. Both Boolean values reproduce it. A numeric zero for the Int key and False for a Bool key serve as controls. No server connection was needed to inspect the generated payload. Investigation and report were AI-assisted.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions