Skip to content

Fix schema validators after collection pre-load changes length#2989

Open
nyxst4ck wants to merge 1 commit into
marshmallow-code:devfrom
nyxst4ck:fix-schema-validator-preload-length
Open

Fix schema validators after collection pre-load changes length#2989
nyxst4ck wants to merge 1 commit into
marshmallow-code:devfrom
nyxst4ck:fix-schema-validator-preload-length

Conversation

@nyxst4ck

Copy link
Copy Markdown

Summary

  • Avoid zipping deserialized many=True items with the original raw collection when a per-item @validates_schema hook did not request pass_original.
  • Add a regression test for @pre_load(pass_collection=True) changing collection length before per-item schema validation.
  • Add @nyxst4ck to AUTHORS.rst per the contribution guidelines.

Root cause

For many=True schema validation, _invoke_schema_validators always used zip(data, original_data, strict=True) for per-item validators. If a collection-level pre-load hook filtered or otherwise changed the number of items, per-item schema validators that did not use pass_original still failed with ValueError from the strict zip, even though original_data is unused in that case.

Test Plan

  • uv run pytest tests/test_decorators.py -k collection_pre_load_can_change_length_before_item_schema_validation -q
  • uv run pytest tests/test_decorators.py -q
  • uv run pytest -q -k "not test_from_timestamp_with_overflow_value"
  • uv run tox -e lint

Also ran uv run pytest -q; it had one unrelated Windows/Python assertion failure in tests/test_utils.py::test_from_timestamp_with_overflow_value because the platform error message was Error converting value to datetime instead of the expected regex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant