Skip to content

feat(ipa): Add IPA-111 validation rules - #1460

Open
mongodb-sage-bot[bot] wants to merge 5 commits into
mainfrom
sage-bot/CLOUDP-439595/sage-CLOUDP-439595-1787849732487
Open

feat(ipa): Add IPA-111 validation rules#1460
mongodb-sage-bot[bot] wants to merge 5 commits into
mainfrom
sage-bot/CLOUDP-439595/sage-CLOUDP-439595-1787849732487

Conversation

@mongodb-sage-bot

@mongodb-sage-bot mongodb-sage-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

Add three new Spectral validation rules enforcing lintable IPA-111 (Default Values) constraints to the IPA Validation Framework:

  • xgen-IPA-111-optional-fields-no-default: optional (non-required) fields must not define a default value. Boolean fields are delegated to the boolean rule below, and fields marked with the new x-xgen-server-computed-when-client-omitted extension are exempt.
  • xgen-IPA-111-effective-fields-read-only: effective-value fields (property names prefixed with effective) must be readOnly: true and must not appear in request schemas.
  • xgen-IPA-111-optional-boolean-fields-default-false: optional boolean fields must default to false.

Also adds the IPA-111.yaml ruleset, registers it in ipa-spectral.yaml, regenerates the ruleset README, and introduces shared helpers isRequiredProperty (schemaUtils) and hasServerComputedWhenClientOmittedExtension (extensions).

Jira ticket: CLOUDP-439595

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works

Changes to Spectral

  • I have read the README file for Spectral Updates

Important

MongoDB Contribution Guidelines

This pull request was generated by sage-bot on behalf of yeliz.henden@mongodb.com (ticket assignee). The assignee must self-review the changes before requesting review from another engineer.
The assignee is not allowed to merge their own PR without approval from another engineer.

## Proposed changes

Add three new Spectral validation rules enforcing lintable IPA-111 (Default Values) constraints to the IPA Validation Framework:

- `xgen-IPA-111-optional-fields-no-default`: optional (non-required) fields must not define a default value. Boolean fields are delegated to the boolean rule below, and fields marked with the new `x-xgen-server-computed-when-client-omitted` extension are exempt.
- `xgen-IPA-111-effective-fields-read-only`: effective-value fields (property names prefixed with `effective`) must be `readOnly: true` and must not appear in request schemas.
- `xgen-IPA-111-optional-boolean-fields-default-false`: optional boolean fields must default to `false`.

Also adds the `IPA-111.yaml` ruleset, registers it in `ipa-spectral.yaml`, regenerates the ruleset README, and introduces shared helpers `isRequiredProperty` (schemaUtils) and `hasServerComputedWhenClientOmittedExtension` (extensions).

_Jira ticket:_ CLOUDP-439595

## 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
@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

@mongodb-sage-bot

mongodb-sage-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Sage Bot - Unexpected Error

Sage Bot ran into an unexpected error processing your request. If you need help, reach out in #ask-devprod.

@yelizhenden-mdb yelizhenden-mdb changed the title CLOUDP-439595: add IPA-111 validation rules feat(ipa): Add IPA-111 validation rules Aug 28, 2026
yelizhenden-mdb and others added 2 commits August 28, 2026 16:47
…lations

The original PR had 64 override entries but the Atlas v2 spec has 318
violations for the three new IPA-111 rules. Without the full list,
ipa-validation would fail with 254 errors.

Added 209 boolean, 96 no-default, and 13 effective overrides (all
tracked under CLOUDP-439952). Verified zero violations on v2.yaml.
@wtrocki

wtrocki commented Sep 3, 2026

Copy link
Copy Markdown
Member

The 3 new rules are correctly implemented and all tests pass. The issue is the override list only covered ~64 of 318 actual violations in the Atlas v2 spec — running ipa-validation against v2.yaml would fail with 254 errors.
I expanded the override list to cover all 318 violations:

  • xgen-IPA-111-optional-boolean-fields-default-false: 44 → 209 entries
  • xgen-IPA-111-optional-fields-no-default: 19 → 96 entries
  • xgen-IPA-111-effective-fields-read-only: 1 → 13 entries

Concern — sheer volume of exceptions: 318 overrides for a single IPA rule is a red flag. The majority are boolean fields in response-only schemas (e.g., BackupSnapshot, DiskBackupSnapshotRestoreJob, ClusterDescriptionProcessArgs) where default: false is semantically irrelevant — the server computes these values.

@yelizhenden-mdb Once we you back we should align and consider:

  1. Scoping optional-boolean-fields-default-false to request schemas only — responses don't benefit from default annotations
  2. Similarly for optional-fields-no-default — response defaults serve as API documentation
  3. Whether the effective-fields rule should only fire in request contexts (already partially done via pathIsForRequestVersion)
    If scoped to requests only, the override list would shrink from 318 to ~50 entries (rough estimate). Worth a follow-up before CLOUDP-439952 gets too large.

I'm going to do provisional change for this so it is easier to make follow up IPA change.

…schemas only

Response schemas and component schemas used in responses are now
excluded from the optional-boolean-fields-default-false and
optional-fields-no-default rules via pathIsForRequestVersion guard.

This reduces the override list from 318 to 13 entries (only
effective-fields-read-only requires component-level overrides).

Also regenerated ruleset README.
@wtrocki
wtrocki marked this pull request as ready for review September 3, 2026 10:43
@wtrocki
wtrocki requested a review from a team as a code owner September 3, 2026 10:43
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