mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-02-16 13:19:07 -06:00
[Python]: Hotfix: Pydantic serialization error from failing to encode bytes (#2602)
* hotfix: handle pydantic serialization errors * chore: changelog * fix(python-sdk): Fix RateLimit validation incorrectly rejects valid CEL expression strings (#2536) * fix(python-sdk): Fix RateLimit validation incorrectly rejects valid CEL expression strings * fix(python-sdk): Update RateLimit validation to use union type for limit instead of tuple syntax * chore(python-sdk): update changelog and bump the patch version to 1.21.4 --------- Co-authored-by: mrkaye97 <mrkaye97@gmail.com> --------- Co-authored-by: miyelani-inc <139712015+miyelani-inc@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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 <alexander@hatchet.run>",
|
||||
|
||||
Reference in New Issue
Block a user