fix!: apply to_camel alias generator to all Pydantic models#950
Draft
vdusek wants to merge 2 commits into
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #950 +/- ##
==========================================
+ Coverage 86.88% 87.02% +0.14%
==========================================
Files 48 48
Lines 2943 2960 +17
==========================================
+ Hits 2557 2576 +19
+ Misses 386 384 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
BREAKING CHANGE: every Pydantic model except Configuration now derives its JSON aliases from snake_case field names via to_camel, so by-alias serialization is uniformly camelCase. ActorRunUsage/ActorRunUsageUsd keys change from ACTOR_COMPUTE_UNITS-style to actorComputeUnits-style, and RequestQueueHead from lockSecs to lockTime. The legacy keys are still accepted on input for backwards compatibility. Attribute names are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #949.
Warning
Breaking change (targets the v4 major). The wire keys produced by by-alias serialization change for some models. Reading data stays backwards compatible.
Every Pydantic model in the SDK now derives its JSON field aliases from the snake_case field names with Pydantic's
alias_generator=to_camel, instead of declaring each alias by hand. The config (ConfigDict(populate_by_name=True, alias_generator=to_camel, ...)) is repeated per model rather than shared via a base class.Scope
_models.py,storage_clients/_apify/_models.py,events/_types.py, andrequest_loaders/_apify_request_list.py.Configurationis the only model left untouched, because its fields map toAPIFY_*/CRAWLEE_*environment variables via validation aliases. Applyingto_camelthere would break env-based configuration.Breaking changes
Attribute names are unchanged (
run.usage.actor_compute_unitsstill works). Only by-alias serialization keys change, and only where they were not already camelCase:ActorRunUsage/ActorRunUsageUsd:ACTOR_COMPUTE_UNITS,DATASET_READS, … →actorComputeUnits,datasetReads, …RequestQueueHead:lockSecs→lockTime.Backwards compatibility
Validation still accepts the previous keys, so existing API payloads and stored data keep parsing:
AliasChoices).RequestQueueHeadaccepts bothlockTimeand the legacylockSecs.Docs
Documented in the v4 upgrading guide (
docs/04_upgrading/upgrading_to_v4.md).