Skip to content

Raise ValueError for naive datetime search attributes - #1882

Open
KingLizard1020 wants to merge 2 commits into
temporalio:mainfrom
KingLizard1020:cursor/datetime-search-attr-tz-0487
Open

KingLizard1020 wants to merge 2 commits into
temporalio:mainfrom
KingLizard1020:cursor/datetime-search-attr-tz-0487

Conversation

@KingLizard1020

Copy link
Copy Markdown

Summary

Addresses temporalio/sdk-python#611. Related: #572.

encode_typed_search_attribute_value now raises ValueError("Timezone must be present on all search attribute dates") when encoding a datetime search attribute that lacks a timezone. This matches the deprecated untyped encode_search_attribute_values path.

Previously the typed path called isoformat() on naive datetimes and sent a string the server rejected with BadSearchAttributes. Both upsert_search_attributes and client-side typed attributes go through the typed encoder, so this covers both.

Raising (rather than warning) is intentional: these values already failed on the server, and matching the untyped encoder keeps one client-side contract.

Test plan

  • Added test_encode_typed_search_attribute_value_datetime_requires_timezone next to test_encode_search_attribute_values. Naive datetimes raise; timezone-aware datetimes still encode.
  • Ran locally: uv run pytest tests/test_converter.py — 33 passed, including the new regression test and test_encode_search_attribute_values.

@KingLizard1020
KingLizard1020 requested a review from a team as a code owner September 17, 2026 16:58
@CLAassistant

CLAassistant commented Sep 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Mirror the untyped encoder timezone check into the typed path so
upserting or encoding a datetime search attribute without tzinfo
fails client-side instead of as a server BadSearchAttributes error.

Signed-off-by: Kailash Nelson <37966146+KingLizard1020@users.noreply.github.com>
@github-actions
github-actions Bot force-pushed the cursor/datetime-search-attr-tz-0487 branch from cb5b372 to 825e69c Compare September 17, 2026 17:34
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.

3 participants