Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AvoidAdditionalProperties] Allow under any property matching regex "[Tt]ags" instead of exactly "tags" #698

Closed
mikeharder opened this issue Jun 1, 2024 · 1 comment
Assignees

Comments

@mikeharder
Copy link
Member

mikeharder commented Jun 1, 2024

Rule AvoidAdditionalProperties raised an error for the following swagger:

"vmTags": {
  "type": "object",
  "additionalProperties": {
    "type": "string"
  },
  "description": "Hashtable that lists key/value pair tags to apply to the VMs"
},

Currently, additionalProperties is only automatically allowed under properties named exactly tags:

description: "Definitions must not have properties named additionalProperties except for user defined tags or predefined references.",
severity: "error",
message: "{{description}}",
disableForTypeSpec: true,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/no-record' rule.",
resolved: true,
formats: [oas2],
// In some cases, variable "@" will be "null" when evaluating the expression, so it must be checked before dereferencing
given:
"$.definitions..[?(@property !== 'tags' && @property !== 'delegatedResources' && @property !== 'userAssignedIdentities' && @ && @.additionalProperties)]",

The proposal is to broaden the range of allowed properties, to anything matching regex [Tt]ags (or something similar that would allow vmTags).

We may also need to align with RPC-Policy-V1-05 and RPC-Put-V1-23 which are mentioned here:

https://github.com/Azure/azure-openapi-validator/blob/b95d5eb121c47ab3e110c97da23e583ebfd637ee/docs/avoid-additional-properties.md#related-arm-guideline-code

The status quo is to require suppressions for properties with names similar to (but not exactly) tags.

Spec PR: https://github.com/Azure/azure-rest-api-specs/pull/29101/checks?check_run_id=25631949240

CC: @markcowl, @almat-msft

@mikeharder mikeharder self-assigned this Jun 1, 2024
@mikeharder
Copy link
Member Author

We believe the root cause is more related to #652 than the name of the property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Status: 🎊 Closed
Development

No branches or pull requests

1 participant