feat(ipa): Add IPA-111 validation rules - #1460
Conversation
## 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
|
Sage Bot can help with this pull request. Just |
|
❌ Sage Bot - Unexpected Error Sage Bot ran into an unexpected error processing your request. If you need help, reach out in #ask-devprod. |
…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.
|
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.
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:
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.
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 newx-xgen-server-computed-when-client-omittedextension are exempt.xgen-IPA-111-effective-fields-read-only: effective-value fields (property names prefixed witheffective) must bereadOnly: trueand must not appear in request schemas.xgen-IPA-111-optional-boolean-fields-default-false: optional boolean fields must default tofalse.Also adds the
IPA-111.yamlruleset, registers it inipa-spectral.yaml, regenerates the ruleset README, and introduces shared helpersisRequiredProperty(schemaUtils) andhasServerComputedWhenClientOmittedExtension(extensions).Jira ticket: CLOUDP-439595
Checklist
Changes to Spectral
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.