refactor: unify alias vs validation_alias usage in Pydantic models#1022
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1022 +/- ##
==========================================
- Coverage 91.72% 91.69% -0.03%
==========================================
Files 50 50
Lines 3213 3215 +2
==========================================
+ Hits 2947 2948 +1
- Misses 266 267 +1
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:
|
Pijukatel
approved these changes
Jul 3, 2026
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.
Pydantic's
aliassets both the validation and the serialization name, whilevalidation_aliasaffects only validation.Configurationmixed the two, somodel_dump(by_alias=True)was incoherent — e.g.is_at_homedumped asapify_is_at_homebutstarted_atdumped asstarted_at.This makes serialization consistent:
model_dump(by_alias=True)now emits camelCase names derived from the Python field name across all Pydantic models._configuration.py— each field is validated from its environment variable(s) viavalidation_alias(a plain string, orAliasChoices(...)for legacy names). Serialization is handled by a model-levelalias_generator=AliasGenerator(serialization_alias=to_camel), so e.g.is_at_home→isAtHome,actor_id→actorId,max_paid_dataset_items→maxPaidDatasetItems. This also covers the fields inherited from Crawlee's baseConfiguration._charging.py,events/_types.py,storage_clients/_apify/_models.py,request_loaders/_apify_request_list.py) already serialize camelCase viaalias_generator=to_camel;RequestQueueHead.lock_timekeeps its explicitserialization_alias='lockSecs'where the wire name differs from the field-derived one. Left as-is.CLAUDE.md— documents the convention.One inherited Crawlee field,
internal_timeout, is defined withalias='crawlee_internal_timeout'(notvalidation_alias), which pins its serialization so the generator can't override it. It's outside this repo's control.Closes #807