Skip to content

Commit 5a82c9a

Browse files
fix(ipa): make operation ID rules error-level (#932)
1 parent 78de865 commit 5a82c9a

18 files changed

+130
-52
lines changed

tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ testRule('xgen-IPA-104-valid-operation-id', [
3131
code: 'xgen-IPA-104-valid-operation-id',
3232
message: "Invalid OperationID. Found 'getProjectIpList', expected 'getGroupAccessList'. ",
3333
path: ['paths', '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}', 'get', 'operationId'],
34-
severity: DiagnosticSeverity.Warning,
34+
severity: DiagnosticSeverity.Error,
3535
},
3636
],
3737
},
@@ -52,14 +52,14 @@ testRule('xgen-IPA-104-valid-operation-id', [
5252
message:
5353
"Invalid OperationID. Found 'listAlertConfigurationsByAlertId', expected 'getGroupAlertAlertConfigs'. ",
5454
path: ['paths', '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs', 'get', 'operationId'],
55-
severity: DiagnosticSeverity.Warning,
55+
severity: DiagnosticSeverity.Error,
5656
},
5757
{
5858
code: 'xgen-IPA-104-valid-operation-id',
5959
message:
6060
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
6161
path: ['paths', '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs', 'get', 'operationId'],
62-
severity: DiagnosticSeverity.Warning,
62+
severity: DiagnosticSeverity.Error,
6363
},
6464
],
6565
},
@@ -109,7 +109,7 @@ testRule('xgen-IPA-104-valid-operation-id', [
109109
'get',
110110
'x-xgen-operation-id-override',
111111
],
112-
severity: DiagnosticSeverity.Warning,
112+
severity: DiagnosticSeverity.Error,
113113
},
114114
{
115115
code: 'xgen-IPA-104-valid-operation-id',
@@ -120,7 +120,7 @@ testRule('xgen-IPA-104-valid-operation-id', [
120120
'get',
121121
'x-xgen-operation-id-override',
122122
],
123-
severity: DiagnosticSeverity.Warning,
123+
severity: DiagnosticSeverity.Error,
124124
},
125125
],
126126
},

tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ testRule('xgen-IPA-105-valid-operation-id', [
3131
code: 'xgen-IPA-105-valid-operation-id',
3232
message: "Invalid OperationID. Found 'getApiVersions', expected 'listOpenapiVersions'. ",
3333
path: ['paths', '/api/atlas/v2/unauth/openapi/versions', 'get', 'operationId'],
34-
severity: DiagnosticSeverity.Warning,
34+
severity: DiagnosticSeverity.Error,
3535
},
3636
],
3737
},
@@ -52,14 +52,14 @@ testRule('xgen-IPA-105-valid-operation-id', [
5252
message:
5353
"Invalid OperationID. Found 'returnAllControlPlaneIpAddresses', expected 'listControlPlaneIpAddresses'. ",
5454
path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'],
55-
severity: DiagnosticSeverity.Warning,
55+
severity: DiagnosticSeverity.Error,
5656
},
5757
{
5858
code: 'xgen-IPA-105-valid-operation-id',
5959
message:
6060
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
6161
path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'],
62-
severity: DiagnosticSeverity.Warning,
62+
severity: DiagnosticSeverity.Error,
6363
},
6464
],
6565
},
@@ -101,13 +101,13 @@ testRule('xgen-IPA-105-valid-operation-id', [
101101
message:
102102
"The operation ID override must only contain nouns from the operation ID 'listGroupBackupExportBuckets'. ",
103103
path: ['paths', '/api/atlas/v2/groups/{groupId}/backup/exportBuckets', 'get', 'x-xgen-operation-id-override'],
104-
severity: DiagnosticSeverity.Warning,
104+
severity: DiagnosticSeverity.Error,
105105
},
106106
{
107107
code: 'xgen-IPA-105-valid-operation-id',
108108
message: "The operation ID override must end with the noun 'Buckets'. ",
109109
path: ['paths', '/api/atlas/v2/groups/{groupId}/backup/exportBuckets', 'get', 'x-xgen-operation-id-override'],
110-
severity: DiagnosticSeverity.Warning,
110+
severity: DiagnosticSeverity.Error,
111111
},
112112
],
113113
},

tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ testRule('xgen-IPA-106-valid-operation-id', [
3636
code: 'xgen-IPA-106-valid-operation-id',
3737
message: "Invalid OperationID. Found 'addUserToProject', expected 'createGroupAccess'. ",
3838
path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post', 'operationId'],
39-
severity: DiagnosticSeverity.Warning,
39+
severity: DiagnosticSeverity.Error,
4040
},
4141
{
4242
code: 'xgen-IPA-106-valid-operation-id',
4343
message: "Invalid OperationID. Found 'createProjectInvitation', expected 'createGroupInvite'. ",
4444
path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post', 'operationId'],
45-
severity: DiagnosticSeverity.Warning,
45+
severity: DiagnosticSeverity.Error,
4646
},
4747
],
4848
},
@@ -63,14 +63,14 @@ testRule('xgen-IPA-106-valid-operation-id', [
6363
message:
6464
"Invalid OperationID. Found 'createServiceAccountAccessList', expected 'createOrgServiceAccountAccessList'. ",
6565
path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'],
66-
severity: DiagnosticSeverity.Warning,
66+
severity: DiagnosticSeverity.Error,
6767
},
6868
{
6969
code: 'xgen-IPA-106-valid-operation-id',
7070
message:
7171
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
7272
path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'],
73-
severity: DiagnosticSeverity.Warning,
73+
severity: DiagnosticSeverity.Error,
7474
},
7575
],
7676
},
@@ -110,7 +110,7 @@ testRule('xgen-IPA-106-valid-operation-id', [
110110
'post',
111111
'x-xgen-operation-id-override',
112112
],
113-
severity: DiagnosticSeverity.Warning,
113+
severity: DiagnosticSeverity.Error,
114114
},
115115
{
116116
code: 'xgen-IPA-106-valid-operation-id',
@@ -122,7 +122,7 @@ testRule('xgen-IPA-106-valid-operation-id', [
122122
'post',
123123
'x-xgen-operation-id-override',
124124
],
125-
severity: DiagnosticSeverity.Warning,
125+
severity: DiagnosticSeverity.Error,
126126
},
127127
{
128128
code: 'xgen-IPA-106-valid-operation-id',
@@ -133,7 +133,7 @@ testRule('xgen-IPA-106-valid-operation-id', [
133133
'post',
134134
'x-xgen-operation-id-override',
135135
],
136-
severity: DiagnosticSeverity.Warning,
136+
severity: DiagnosticSeverity.Error,
137137
},
138138
],
139139
},
@@ -144,7 +144,10 @@ testRule('xgen-IPA-106-valid-operation-id', [
144144
'/api/atlas/v2/groups/{groupId}/serverless': {
145145
post: {
146146
operationId: 'createGroupServerlessInstance',
147-
'x-xgen-method-verb-override': { verb: 'createInstance', customMethod: false },
147+
'x-xgen-method-verb-override': {
148+
verb: 'createInstance',
149+
customMethod: false,
150+
},
148151
'x-xgen-operation-id-override': 'createServerlessInstance',
149152
},
150153
},

tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ testRule('xgen-IPA-107-valid-operation-id', [
4141
code: 'xgen-IPA-107-valid-operation-id',
4242
message: "Invalid OperationID. Found 'setProjectLimit', expected 'updateGroupLimit'. ",
4343
path: ['paths', '/api/atlas/v2/groups/{groupId}/limits/{limitName}', 'patch', 'operationId'],
44-
severity: DiagnosticSeverity.Warning,
44+
severity: DiagnosticSeverity.Error,
4545
},
4646
{
4747
code: 'xgen-IPA-107-valid-operation-id',
4848
message: "Invalid OperationID. Found 'updateProjectSettings', expected 'updateGroupSettings'. ",
4949
path: ['paths', '/api/atlas/v2/groups/{groupId}/settings', 'put', 'operationId'],
50-
severity: DiagnosticSeverity.Warning,
50+
severity: DiagnosticSeverity.Error,
5151
},
5252
],
5353
},
@@ -68,14 +68,14 @@ testRule('xgen-IPA-107-valid-operation-id', [
6868
message:
6969
"Invalid OperationID. Found 'updatePushBasedLogConfiguration', expected 'updateGroupPushBasedLogExport'. ",
7070
path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'],
71-
severity: DiagnosticSeverity.Warning,
71+
severity: DiagnosticSeverity.Error,
7272
},
7373
{
7474
code: 'xgen-IPA-107-valid-operation-id',
7575
message:
7676
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
7777
path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'],
78-
severity: DiagnosticSeverity.Warning,
78+
severity: DiagnosticSeverity.Error,
7979
},
8080
],
8181
},
@@ -116,7 +116,7 @@ testRule('xgen-IPA-107-valid-operation-id', [
116116
'patch',
117117
'x-xgen-operation-id-override',
118118
],
119-
severity: DiagnosticSeverity.Warning,
119+
severity: DiagnosticSeverity.Error,
120120
},
121121
{
122122
code: 'xgen-IPA-107-valid-operation-id',
@@ -127,7 +127,7 @@ testRule('xgen-IPA-107-valid-operation-id', [
127127
'patch',
128128
'x-xgen-operation-id-override',
129129
],
130-
severity: DiagnosticSeverity.Warning,
130+
severity: DiagnosticSeverity.Error,
131131
},
132132
],
133133
},
@@ -138,7 +138,10 @@ testRule('xgen-IPA-107-valid-operation-id', [
138138
'/api/atlas/v2/groups/{groupId}/serverless': {
139139
patch: {
140140
operationId: 'updateGroupServerlessInstance',
141-
'x-xgen-method-verb-override': { verb: 'updateInstance', customMethod: false },
141+
'x-xgen-method-verb-override': {
142+
verb: 'updateInstance',
143+
customMethod: false,
144+
},
142145
'x-xgen-operation-id-override': 'updateServerlessInstance',
143146
},
144147
},

tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ testRule('xgen-IPA-108-valid-operation-id', [
3636
code: 'xgen-IPA-108-valid-operation-id',
3737
message: "Invalid OperationID. Found 'removeProjectApiKey', expected 'deleteGroupApiKey'. ",
3838
path: ['paths', '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}', 'delete', 'operationId'],
39-
severity: DiagnosticSeverity.Warning,
39+
severity: DiagnosticSeverity.Error,
4040
},
4141
{
4242
code: 'xgen-IPA-108-valid-operation-id',
4343
message: "Invalid OperationID. Found 'deleteProject', expected 'deleteGroup'. ",
4444
path: ['paths', '/api/atlas/v2/groups/{groupId}', 'delete', 'operationId'],
45-
severity: DiagnosticSeverity.Warning,
45+
severity: DiagnosticSeverity.Error,
4646
},
4747
],
4848
},
@@ -68,7 +68,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
6868
'delete',
6969
'operationId',
7070
],
71-
severity: DiagnosticSeverity.Warning,
71+
severity: DiagnosticSeverity.Error,
7272
},
7373
{
7474
code: 'xgen-IPA-108-valid-operation-id',
@@ -80,7 +80,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
8080
'delete',
8181
'operationId',
8282
],
83-
severity: DiagnosticSeverity.Warning,
83+
severity: DiagnosticSeverity.Error,
8484
},
8585
],
8686
},
@@ -121,7 +121,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
121121
'delete',
122122
'x-xgen-operation-id-override',
123123
],
124-
severity: DiagnosticSeverity.Warning,
124+
severity: DiagnosticSeverity.Error,
125125
},
126126
{
127127
code: 'xgen-IPA-108-valid-operation-id',
@@ -132,7 +132,7 @@ testRule('xgen-IPA-108-valid-operation-id', [
132132
'delete',
133133
'x-xgen-operation-id-override',
134134
],
135-
severity: DiagnosticSeverity.Warning,
135+
severity: DiagnosticSeverity.Error,
136136
},
137137
],
138138
},
@@ -143,7 +143,10 @@ testRule('xgen-IPA-108-valid-operation-id', [
143143
'/api/atlas/v2/groups/{groupId}/serverless': {
144144
delete: {
145145
operationId: 'deleteGroupServerlessInstance',
146-
'x-xgen-method-verb-override': { verb: 'deleteInstance', customMethod: false },
146+
'x-xgen-method-verb-override': {
147+
verb: 'deleteInstance',
148+
customMethod: false,
149+
},
147150
'x-xgen-operation-id-override': 'deleteServerlessInstance',
148151
},
149152
},

tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ testRule('xgen-IPA-109-valid-operation-id', [
3636
code: 'xgen-IPA-109-valid-operation-id',
3737
message: "Invalid OperationID. Found 'searchClusters', expected 'searchGroupClusters'. ",
3838
path: ['paths', '/api/atlas/v2/groups/{groupId}/clusters:search', 'post', 'operationId'],
39-
severity: DiagnosticSeverity.Warning,
39+
severity: DiagnosticSeverity.Error,
4040
},
4141
],
4242
},
@@ -56,14 +56,14 @@ testRule('xgen-IPA-109-valid-operation-id', [
5656
code: 'xgen-IPA-109-valid-operation-id',
5757
message: "Invalid OperationID. Found 'migrateProjectToAnotherOrg', expected 'migrateGroup'. ",
5858
path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate', 'post', 'operationId'],
59-
severity: DiagnosticSeverity.Warning,
59+
severity: DiagnosticSeverity.Error,
6060
},
6161
{
6262
code: 'xgen-IPA-109-valid-operation-id',
6363
message:
6464
"The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ",
6565
path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate', 'post', 'operationId'],
66-
severity: DiagnosticSeverity.Warning,
66+
severity: DiagnosticSeverity.Error,
6767
},
6868
],
6969
},
@@ -118,7 +118,7 @@ testRule('xgen-IPA-109-valid-operation-id', [
118118
'delete',
119119
'x-xgen-operation-id-override',
120120
],
121-
severity: DiagnosticSeverity.Warning,
121+
severity: DiagnosticSeverity.Error,
122122
},
123123
{
124124
code: 'xgen-IPA-109-valid-operation-id',
@@ -129,7 +129,7 @@ testRule('xgen-IPA-109-valid-operation-id', [
129129
'delete',
130130
'x-xgen-operation-id-override',
131131
],
132-
severity: DiagnosticSeverity.Warning,
132+
severity: DiagnosticSeverity.Error,
133133
},
134134
],
135135
},

tools/spectral/ipa/__tests__/metrics/data/collector-results.log

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
{
44
"componentId": "paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get",
55
"ruleName": "xgen-IPA-104-valid-operation-id"
6-
}],
6+
},
7+
{
8+
"componentId": "paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get",
9+
"ruleName": "xgen-IPA-104-valid-operation-id-warn"
10+
}
11+
],
712
"adoptions": [
813
{
914
"componentId": "paths./api/atlas/v2",

tools/spectral/ipa/__tests__/metrics/data/expected-metric-results.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,16 @@
17521752
"component_id": "paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get",
17531753
"ipa_rule": "xgen-IPA-104-valid-operation-id",
17541754
"ipa": "IPA-104",
1755+
"severity_level": "error",
1756+
"adoption_status": "violated",
1757+
"exception_reason": null,
1758+
"owner_team": null,
1759+
"timestamp": "2025-01-21T16:45:11.681Z"
1760+
},
1761+
{
1762+
"component_id": "paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get",
1763+
"ipa_rule": "xgen-IPA-104-valid-operation-id-warn",
1764+
"ipa": "IPA-104",
17551765
"severity_level": "warn",
17561766
"adoption_status": "violated",
17571767
"exception_reason": null,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
11
extends:
22
- ../../../rulesets/IPA-104.yaml
3+
4+
functionsDir: '../../../rulesets/functions'
5+
6+
functions:
7+
- IPA104ValidOperationID
8+
9+
aliases:
10+
GetOperationObject:
11+
- '$.paths[*].get'
12+
13+
rules:
14+
xgen-IPA-104-valid-operation-id-warn:
15+
description: Test rule as warning for testing purposes
16+
message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-valid-operation-id'
17+
severity: warn
18+
given: '#GetOperationObject'
19+
then:
20+
function: 'IPA104ValidOperationID'
21+
functionOptions:
22+
methodName: 'get'
23+
ignoreSingularizationList:
24+
- 'Fts'

tools/spectral/ipa/__tests__/metrics/metricCollection.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('tools/spectral/ipa/metrics/metricCollection.js runMetricCollectionJob'
4444
expect(results.warnings.count).toEqual(1);
4545
const violations = [
4646
{
47-
code: 'xgen-IPA-104-valid-operation-id',
47+
code: 'xgen-IPA-104-valid-operation-id-warn',
4848
},
4949
];
5050
expect(results.warnings.violations).toEqual(violations);

0 commit comments

Comments
 (0)