Skip to content

Conversation

@ubik2
Copy link
Contributor

@ubik2 ubik2 commented Jul 31, 2025

JSONSchema defaults this to true, but we want an intermediate behavior where if it's missing, we don't traverse the property, but we also don't reject the object as invalid.

The {} value is still treated as a true schema, and will traverse the property values.


Summary by cubic

Changed how missing additionalProperties in JSONSchema is handled. Now, if additionalProperties is not set, we skip traversing unknown properties but do not mark the object as invalid.

  • Bug Fixes
    • Updated schema traversal logic to treat absent additionalProperties as "do not traverse" instead of defaulting to true.
    • Added tests to cover this behavior.

JSONSchema defaults this to true, but we want an intermediate behavior where if it's missing, we don't traverse the property, but we also don't reject the object as invalid.
// don't invalidate the object, but also don't descend down
// into that property.
if (propSchema === undefined) {
filteredObj[propKey] = propValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we even assign it? It shouldn't be sent to an untrusted function (i.e. CFC will base it's decision on the assumption it isn't sent)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the current use cases, this lets you have a required property that's in the additionalProperties.
The returned object isn't actually used right now, so it's not a CFC issue (we will return the entire doc for each doc we use). If we do want to prevent it from being included, we can also specify additionalProperties false.

However, when evaluating this to determine whether we can access a field, it might be best to prevent reads/writes. I'll keep this in mind when I tackle that.

@ubik2 ubik2 merged commit e8d2d64 into main Jul 31, 2025
8 checks passed
@ubik2 ubik2 deleted the feat/additional-properties-ignore branch July 31, 2025 03:08
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.

3 participants