Skip to content

Conversation

lovisaberggren
Copy link
Collaborator

@lovisaberggren lovisaberggren commented Aug 11, 2025

Proposed changes

This PR introduces a new helper function to handle all violations, exceptions and adoptions for a rule.

The idea is that when violations are collected in a rule, this function gets called to handle metric collection as well as silencing violations with exceptions.

Additionally, thing brings the functionality to error if there are no violations, but the component still has exceptions. This allows us to remove unnecessary exceptions in the OAS.

For now IPA 005-104 are updated using the new helper function. I'll adjust the other IPAs in incremental follow-up PRs to keep the PRs smaller.

Finally, I'll update the OAS and remove identified exceptions that are no longer needed + remove temporary Spectral overrides.

Jira ticket: CLOUDP-307585

Exceptions found that can be removed:

error  xgen-IPA-104-get-method-response-has-no-input-fields  This component adopts the rule and does not need an exception. Please remove the exception. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-response-has-no-input-fields  paths./api/atlas/v2/groups/{groupId}.get.responses[200].content.application/vnd.atlas.2023-01-01+json.x-xgen-IPA-exception.xgen-IPA-104-get-method-response-has-no-input-fields

error  xgen-IPA-104-get-method-response-has-no-input-fields  This component adopts the rule and does not need an exception. Please remove the exception. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-response-has-no-input-fields  paths./api/atlas/v2/orgs/{orgId}/groups.get.responses[200].content.application/vnd.atlas.2023-01-01+json.x-xgen-IPA-exception.xgen-IPA-104-get-method-response-has-no-input-fields

@lovisaberggren lovisaberggren marked this pull request as ready for review August 11, 2025 15:49
@lovisaberggren lovisaberggren requested a review from a team as a code owner August 11, 2025 15:49
* @param {Array<string>} objectPath the JSON path to the object
* @returns {Array<{path: Array<string>, message: string}>|undefined} an array of the validation errors, or undefined if there are no errors
*/
export function collectExceptionAdoptionViolations(validationErrors, ruleName, object, objectPath) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am looking for a better function name, what about evaluateAndCollectAdoptionStatus or something like that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It might apply to the function below as well, if we are allowed to use same function name with different signature

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree the name is bad :) evaluateAndCollectAdoptionStatus sounds good!

No you can't have the same name with different params unfortunately, I'll name it evaluateAndCollectAdoptionStatusWithoutExceptions for now, it's a bit long but let me know what you think

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good to me, we'll change it later if we can find any better. Thanks!

Copy link
Collaborator

@yelizhenden-mdb yelizhenden-mdb left a comment

Choose a reason for hiding this comment

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

LGTM!

@lovisaberggren lovisaberggren merged commit 44e9cfa into main Aug 12, 2025
11 checks passed
@lovisaberggren lovisaberggren deleted the CLOUDP-307585 branch August 12, 2025 09:04
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