Fix: enforce restrictMetadata for non-system attributes even when allowSystemMetadata is true#153
Conversation
…allowSystemMetadata is true Co-authored-by: dinhys <31490208+dinhys@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
This PR narrows the allowSystemMetadata=true exemption so that DOC (Data Object Configuration) metadata validation is only skipped for explicitly recognized system-generated attributes, while keeping restrictMetadata enforcement for all other attributes.
Changes:
- Updated
restrictMetadatagating so DOC declaration checks are bypassed only when the attribute is insystemGeneratedMetadataAttributesandallowSystemMetadata=true.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // i.e. it is a mandatory or optional metadata for the applicable DOC | ||
| if (restrictMetadata && !allowSystemMetadata) { | ||
| if (restrictMetadata && !(allowSystemMetadata | ||
| && systemGeneratedMetadataAttributes.contains(metadataEntry.getAttribute()))) { |
There was a problem hiding this comment.
The exemption for DOC validation when allowSystemMetadata is true is currently keyed off the global systemGeneratedMetadataAttributes set. That set includes data-object-only system attributes (see constructor) in addition to the smaller collectionSystemGeneratedMetadataAttributeNames list. For collection metadata updates, this means object-only system attributes would also be treated as exempt from DOC validation. Consider using the collection/data-object specific system-attribute lists (or passing the relevant set into validateMetadata) so only resource-appropriate system attributes are exempted.
| && systemGeneratedMetadataAttributes.contains(metadataEntry.getAttribute()))) { | |
| && collectionSystemGeneratedMetadataAttributeNames.contains(metadataEntry.getAttribute()))) { |
When
allowSystemMetadata=true, DOC validation was completely bypassed for all attributes, allowing any undeclared attribute to pass through unchecked—far broader than the intended "permit system-generated metadata updates" scope.Change
Tighten the exemption to only skip DOC validation for attributes explicitly present in
systemGeneratedMetadataAttributes, while still enforcingrestrictMetadatafor everything else.allowSystemMetadata=false→ behavior unchangedallowSystemMetadata=true, system attribute → exempted from DOC validation (intended)allowSystemMetadata=true, non-system attribute → still validated against DOC rules (fixed)✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.