Skip to content

feat(ipa): allow schema-level IPA-112 is-prefix exceptions - #1548

Merged
maks-m-mongo-leaf merged 4 commits into
mainfrom
sage-bot/coding-session/sage-coding-session-1791798071572
Oct 13, 2026
Merged

maks-m-mongo-leaf merged 4 commits into
mainfrom
sage-bot/coding-session/sage-coding-session-1791798071572

Conversation

@mongodb-sage-bot

@mongodb-sage-bot mongodb-sage-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Allow the xgen-IPA-112-boolean-field-names-avoid-is-prefix exception on the schema containing a field, not only on the field itself, so new is* fields on an existing settings schema no longer each need their own exception and approval round.

  • A schema-level exception applies to all fields defined directly on that schema and is counted in the IPA exception metrics; field-level exceptions keep working as before.
  • Field + schema exception → the field-level exception is reported as unnecessary.
  • Schema-level exception that no direct field needs → reported as unnecessary.
  • Fields in nested inline schemas or in allOf/anyOf/oneOf composition need their own exception.
  • Also guards a crash when a non-boolean field carries both exceptions.

Docs updated: rule description (IPA-112.yaml + generated README) and CONTRIBUTING.md.

Jira ticket: CLOUDP-456528

Follow-ups (outside this repo)

  • Release a new @mongodb-js/ipa-validation-ruleset version.
  • MMS: move the GroupSettings exceptions to the schema level (CLOUDP-456101). GroupSettings and GroupSettingsPreview declare their is* fields directly, so the schema-level exception covers them.

Checklist

  • I have added tests that prove my fix is effective or that my feature works

## Proposed changes

Allow the `xgen-IPA-112-boolean-field-names-avoid-is-prefix` exception to be
set on a schema as well as on an individual field. Before this change, only an
exception on the field itself was accepted, so every new `is*` field on an
existing schema (such as project/group settings) needed its own exception and
another round of API champion approval.

- Add `findExceptionInParentSchema` to `utils/exceptions.js`, modeled on
  `findExceptionInPathHierarchy`. It looks up the exception on the schema that
  directly contains the property. If both the field and its schema have the
  exception, it returns an unnecessary-exception error for the field.
- Add `evaluateAndCollectAdoptionStatusWithInheritedException` to
  `collectionUtils.js`. For a field that violates the rule, it records the
  inherited exception (with the schema's reason) against the field's path, so
  schema-level exceptions are still counted in the IPA metrics. Fields that
  follow the rule are counted as adoptions and are not flagged as having an
  unnecessary exception.
- Update `IPA112BooleanFieldNamesAvoidIsPrefix` to use these helpers.
  Field-level exceptions keep working as before.
- Add the schema-level option to the rule's description (IPA-112.yaml and the
  generated rulesets README) and to the exceptions section of CONTRIBUTING.md.

A schema-level exception applies only to the schema's direct properties. Inline
nested object schemas need their own exception.

_Jira ticket:_ CLOUDP-456528

## Checklist

- [ ] I have signed the [MongoDB CLA](https://www.mongodb.com/legal/contributor-agreement)
- [x] I have added tests that prove my fix is effective or that my feature works

### Changes to Spectral
- [x] I have read the [README](../tools/spectral/README.md) file for Spectral Updates

## Further comments

Releasing a new IPA validation version, and switching the MMS group settings
schema to a schema-level exception (removing the per-field exceptions), are
follow-up steps outside this repository change.
@mongodb-sage-bot

Copy link
Copy Markdown
Contributor Author

Sage Bot can help with this pull request. Just @sage-bot in comments and I'll start working on changes in this branch.
Learn more about Sage Bot

@maks-m-mongo-leaf maks-m-mongo-leaf changed the title CLOUDP-456528: Allow schema-level IPA-112 is-prefix exceptions feat(ipa): allow schema-level IPA-112 is-prefix exceptions Oct 12, 2026
- Report a schema-level IPA-112 exception as unnecessary when no field of the schema violates the rule
- Report a field-level exception covered by a schema-level exception with an accurate message instead of "This component adopts the rule"
- Guard findExceptionInParentSchema against undefined properties
- Document that schema-level exceptions apply to direct properties only; fields in nested inline schemas or composition need their own exception
…ields

- Run the schema-level exception necessity check for non-boolean properties too, so a stale exception is reported even when the schema has no direct boolean fields
- Document the unnecessary-exception behavior and metrics counting in the rule description
- Merge the three unnecessary-exception error constructors into one shared helper
- Simplify the IPA-112 rule flow and guard against a missing parent schema when a field has its own exception (fixes a crash for non-boolean fields with both exceptions)
- Add a regression test for the non-boolean field case
@maks-m-mongo-leaf
maks-m-mongo-leaf marked this pull request as ready for review October 13, 2026 10:02
@maks-m-mongo-leaf
maks-m-mongo-leaf requested a review from a team as a code owner October 13, 2026 10:02
@maks-m-mongo-leaf
maks-m-mongo-leaf merged commit f1d2b96 into main Oct 13, 2026
13 checks passed
@maks-m-mongo-leaf
maks-m-mongo-leaf deleted the sage-bot/coding-session/sage-coding-session-1791798071572 branch October 13, 2026 14:46
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.

2 participants