Skip to content

fix input validator type#2986

Merged
mrkaye97 merged 1 commit intohatchet-dev:mainfrom
szvsw:main
Feb 11, 2026
Merged

fix input validator type#2986
mrkaye97 merged 1 commit intohatchet-dev:mainfrom
szvsw:main

Conversation

@szvsw
Copy link
Copy Markdown
Contributor

@szvsw szvsw commented Feb 11, 2026

Description

Fixes an issue introduced in v1.21.0 where the move to using type adapters broke the return type of the BaseWorkflow.input_validator class property method; this method was provided to allow a type checker-friendly way of accessing the input type of a workflow.

Solution is to allow a type friendly version of both the type adapter and the type to be provided.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

What's Changed

  • Adds typed class property for input type
  • Fixes typed class property for input validator

Copilot AI review requested due to automatic review settings February 11, 2026 00:28
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 11, 2026

@szvsw is attempting to deploy a commit to the Hatchet Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Python SDK to correct the exposed type of BaseWorkflow.input_validator (it is a Pydantic TypeAdapter at runtime) and adds a separate accessor for the underlying validator type, along with a patch version bump and changelog entry.

Changes:

  • Bump Python SDK version to 1.23.1.
  • Fix BaseWorkflow.input_validator property typing to TypeAdapter[...] and add input_validator_type.
  • Document the change in CHANGELOG.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
sdks/python/pyproject.toml Patch version bump for the Python SDK release.
sdks/python/hatchet_sdk/runnables/workflow.py Corrects input_validator typing and adds an accessor for the underlying type.
sdks/python/CHANGELOG.md Adds release notes describing the typing fix and new properties.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 265 to +271
@property
def input_validator(self) -> type[TWorkflowInput]:
return cast(type[TWorkflowInput], self.config.input_validator)
def input_validator(self) -> TypeAdapter[TWorkflowInput]:
return cast(TypeAdapter[TWorkflowInput], self.config.input_validator)

@property
def input_validator_type(self) -> type[TWorkflowInput]:
return cast(type[TWorkflowInput], self.config.input_validator._type)
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

A regression test would help prevent this typing/behavior issue from reappearing: add a unit test that constructs a workflow with a custom input_validator and asserts that workflow.input_validator is a TypeAdapter and that workflow.input_validator_type returns the original validator class (and also cover the default EmptyModel case).

Copilot uses AI. Check for mistakes.
Comment on lines +271 to 272
return cast(type[TWorkflowInput], self.config.input_validator._type)

Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

input_validator_type accesses self.config.input_validator._type, which is a private Pydantic TypeAdapter attribute and may change across Pydantic versions (and may not be present in type stubs under strict mypy). Consider deriving the underlying type via a public API (e.g., input_validator.core_schema) or storing the normalized validator type alongside the adapter when building WorkflowConfig so this property doesn’t depend on internals.

Suggested change
return cast(type[TWorkflowInput], self.config.input_validator._type)
schema = self.config.input_validator.core_schema
# For Pydantic model-based validators, the core schema is typically a dict
# with a "cls" entry pointing at the underlying model class.
if isinstance(schema, dict):
cls = schema.get("cls")
if isinstance(cls, type):
return cast(type[TWorkflowInput], cls)
# Fallback: we were unable to determine the type from the public schema.
# Return a broad type while preserving the annotated return type.
return cast(type[TWorkflowInput], Any)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@mrkaye97 mrkaye97 left a comment

Choose a reason for hiding this comment

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

thanks for the fix!

@mrkaye97 mrkaye97 merged commit ec064c9 into hatchet-dev:main Feb 11, 2026
16 of 18 checks passed
@promptless-for-oss
Copy link
Copy Markdown

📝 Documentation updates detected!

New suggestion: Document input_validator and input_validator_type workflow properties


Tip: Configure how Promptless handles changelogs in Agent Settings 📋

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.

4 participants