fix(dpp): refuse a document type schema that is not an object as an invalid contract structure again - #4870
Conversation
…alid contract structure again `parse_can_be_deleted_by_moderators_for_keyword` (#4864) read the `canBeDeletedByModeratorsFor` window with `get_optional_integer` straight on the schema value, which converts the value to a map first. On a document type schema that is not an object it therefore failed with a raw `ValueError("structure error: value is not a map")` before the core parser reached its "document schema must be an object" check, so the refusal changed from `InvalidContractStructure` to `ValueError`. Two drive-abci tests that inject a `null` schema pin the old refusal and have been red on v4.2-dev since the merge. The reader now tolerates a schema that is no object, like every other doctype-level keyword read before the core parser, and a dpp test pins the refusal for null, string and array schemas on both the validated and the stored path. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 31 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR HygieneState: waiting-bots · commit
Self-review is an author attestation that you have read the diff: This check passes when the policy is satisfied; the repository decides whether merging requires it. |
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v4.2-dev #4870 +/- ##
============================================
+ Coverage 86.42% 86.69% +0.26%
============================================
Files 3122 3122
Lines 411564 411724 +160
============================================
+ Hits 355694 356934 +1240
+ Misses 55870 54790 -1080
🚀 New features to boost your workflow:
|
Issue being fixed or feature implemented
Since #4864 merged, two drive-abci tests are red on
v4.2-dev:Both inject
nullas a document type schema and expect the contract to be refused as anInvalidContractStructure. #4864 addedparse_can_be_deleted_by_moderators_for_keyword, which reads thecanBeDeletedByModeratorsForwindow withget_optional_integerdirectly on the schemaValue. That helper converts the value to a map first, so on a schema that is not an object it fails with the raw platform-value error. The generation-3 parser reads every doctype-level keyword before its "document schema must be an object" check, so that raw error replaced the structure refusal. Every sibling reader in that block (indexOnly,canBeDeletedByModerators,immutable, action fees) already tolerates a non-object schema.No base-branch run executed the Rust workspace tests after the merge (skipped, cancelled, or tripped the dirty-runner
[patch]guard), so #4868 was the first PR to show it.What was done?
parse_can_be_deleted_by_moderators_for_keywordreturnsNonefor a schema that is not an object and reads the window throughinner_optional_integer_valueon the map otherwise, like its siblings.null, string or array schema is refused as anInvalidContractStructureon both the validated and the stored path. It fails on the base branch with the exact error above.No consensus change: a contract whose document type schema is not an object was refused before and is refused now; only the error it is refused with is restored.
How Has This Been Tested?
Locally:
cargo test -p dpp --lib -- try_from_schema: 245 passed (including the 17moderators_delete_tests, one new).common/mod.rs: fails withValueError("structure error: value is not a map").cargo test -p drive-abci --lib -- data_contract_create::state::v0::tests: 7 passed (the two red tests included).cargo clippy -p dpp --all-targets -- -D warningsclean;cargo fmt --all --checkclean.Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code