Skip to content

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

Merged
wtrocki merged 5 commits into
mainfrom
sage-bot/CLOUDP-439595/sage-CLOUDP-439595-1787849732487
Sep 11, 2026
Merged

wtrocki merged 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

@wtrocki wtrocki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Needs additional review as I authored several follow up commits

@yelizhenden-mdb

yelizhenden-mdb commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

@wtrocki I agree with the argument that default values only make sense in requests, since the default is what the server applies when the client doesn't supply the parameter value in the request. So maybe we can add a validation to prevent default values defined in response schema fields. How does it sound?

Because, based on my analysis of the current OpenAPI spec, we have default values defined on the fields of some legacy schemas, and most of them are referenced by both request bodies and responses. It might be worth adding a validation that covers the existing legacy cases and prevents future ones.

@wtrocki

wtrocki commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

@wtrocki I agree with the argument that default values only make sense in requests, since the default is what the server applies when the client doesn't supply the parameter value in the request. So maybe we can add a validation to prevent default values defined in response schema fields. How does it sound?

Do we have and if no should we prioritize validation that prevents schema objects from being reused across request and response? If so, that gives us a natural extension point for the "default" response validation.

if we are aligned I'd suggest making small targeted fixes. Starting with IPA clarification, then refining the broader steps. I think an AI bot handles the immediate task well — addressing the sensible, non-negotiable IPA gaps.

Because, based on my analysis of the current OpenAPI spec, we have default values defined on the fields of some legacy schemas, and most of them are referenced by both request bodies and responses. It might be worth adding a validation that covers the existing legacy cases and prevents future ones.

Yes. Thus this will create +300 exceptions overall and will make even more in future due to reusal of the existing legacy objects in the new feature work.

@wtrocki

wtrocki commented Sep 10, 2026

Copy link
Copy Markdown
Member

Discussed offline. @wtrocki to create set of tickets to cover gaps. PR addressing very specific problem as of now and can be approved.

@wtrocki
wtrocki merged commit 11d08bc into main Sep 11, 2026
7 checks passed
@wtrocki
wtrocki deleted the sage-bot/CLOUDP-439595/sage-CLOUDP-439595-1787849732487 branch September 11, 2026 13:26
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