Repository navigation
Conversation
A payload with many undeclared keys currently rebuilds the model and its nested attributes once per key. Recover later missing writers during one retry so casting stays bounded while preserving unknown-key round trips and strict direct construction.
imacomber
marked this pull request as draft
October 8, 2026 12:24
The recovery path has to preserve several ActiveModel and custom initializer behaviors. Make its Hash propagation and missing-writer checks easier to follow without changing the cast result. Spell out the optional nil value in the duplicate-key fallback.
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.
Fixes #239
Related: #202
What
When a stored model has undeclared keys, StoreModel currently removes one key and casts the entire payload again for each
UnknownAttributeError. That rebuilds nested models on every retry.After the first missing-writer error, this change removes that key as before and retries construction once with a plain Hash that records later unknown keys during attribute assignment. It keeps direct
Model.newstrict and preserves unknown values through serialization.Why
When dealing with large models containing nested objects, the raise and re-cast can start to take a long time.