diff --git a/sdks/python/CHANGELOG.md b/sdks/python/CHANGELOG.md index 46675e8a9..0c6ef7004 100644 --- a/sdks/python/CHANGELOG.md +++ b/sdks/python/CHANGELOG.md @@ -5,6 +5,23 @@ All notable changes to Hatchet's Python SDK will be documented in this changelog The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.21.4] - 2025-12-06 + +### Added + +- Adds support for dynamic rate limits using CEL expressions (strings) for the `limit` parameter. + +### Changed + +- Fixes a serialization error caused by Pydantic sometimes being unable to encode bytes, reported here: https://github.com/hatchet-dev/hatchet/issues/2601 +- Fixes a bug where string-based CEL expressions for `limit` were rejected due to the validation logic. + +## [1.21.3] - 2025-11-26 + +### Added + +- Adds GZIP compression for gRPC communication between the SDK and the Hatchet engine to reduce bandwidth usage. + ## [1.21.2] - 2025-11-13 ### Added diff --git a/sdks/python/hatchet_sdk/rate_limit.py b/sdks/python/hatchet_sdk/rate_limit.py index 8603d5f03..b20f25aff 100644 --- a/sdks/python/hatchet_sdk/rate_limit.py +++ b/sdks/python/hatchet_sdk/rate_limit.py @@ -62,8 +62,8 @@ class RateLimit(BaseModel): if self.dynamic_key and self.static_key: raise ValueError("Cannot have both static key and dynamic key set") - if self.limit and not isinstance(self.limit, int): - raise ValueError(f"Invalid CEL expression: {self.limit}") + if self.limit and not isinstance(self.limit, int | str): + raise ValueError(f"Invalid limit value: {self.limit}") if self.dynamic_key and not self.limit: raise ValueError("CEL based keys requires limit to be set") diff --git a/sdks/python/hatchet_sdk/worker/runner/runner.py b/sdks/python/hatchet_sdk/worker/runner/runner.py index e1aa4fd90..5f7229591 100644 --- a/sdks/python/hatchet_sdk/worker/runner/runner.py +++ b/sdks/python/hatchet_sdk/worker/runner/runner.py @@ -480,7 +480,14 @@ class Runner: return "" if isinstance(output, BaseModel): - output = output.model_dump(mode="json") + try: + output = output.model_dump(mode="json") + except Exception as e: + logger.exception("could not serialize pydantic model output") + + raise IllegalTaskOutputError( + f"could not serialize Pydantic BaseModel output: {e}" + ) from e elif is_dataclass(output): output = asdict(cast(DataclassInstance, output)) diff --git a/sdks/python/pyproject.toml b/sdks/python/pyproject.toml index ec9e024cf..dc71b4e74 100644 --- a/sdks/python/pyproject.toml +++ b/sdks/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "hatchet-sdk" -version = "1.21.3" +version = "1.21.4" description = "This is the official Python SDK for Hatchet, a distributed, fault-tolerant task queue. The SDK allows you to easily integrate Hatchet's task scheduling and workflow orchestration capabilities into your Python applications." authors = [ "Alexander Belanger ",