Skip to content

RequestSchemaForTrackedResourcesMustHaveTags is incorrectly triggered for a Proxy resource with top-level property Location #753

@abatishchev

Description

@abatishchev

Describe the bug
To Reproduce

Given a proxy resource (such as inherited from common type ProxyResource) which has a top-level property location:

model ProxyAccount is ProxyResource<ProxyAccountProperties> {
  name: string;
  location: ProxyAccountLocation;
}

union ProxyAccountLocation {
  Global: "global",
  string,
}

@armResourceOperations
interface ProxyAccounts {
  get is ArmResourceRead<ProxyAccount>;
  create is ArmResourceCreateOrReplaceAsync<ProxyAccount>;
  update is ArmResourcePatchAsync<ProxyAccount, ProxyAccountProperties>;
  delete is ArmResourceDeleteWithoutOkAsync<ProxyAccount>;
  listByResourceGroup is ArmResourceListByParent<ProxyAccount>;
  listBySubscription is ArmListBySubscription<ProxyAccount>;
}

What results in the following swagger:

"ProxyAccount": {
  "type": "object",
  "description": "Proxy account",
  "properties": {
    "properties": {
      "$ref": "#/definitions/ProxyAccountProperties",
      "description": "The resource-specific properties for this resource."
    },
    "location": {
      "$ref": "#/definitions/ProxyAccountLocation",
      "description": "Proxy account location",
      "x-ms-mutability": [
        "read",
        "create"
      ]
    }
  },
  "required": [
    "location"
  ],
  "allOf": [
    {
      "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ProxyResource"
    }
  ]
}

triggers the following Linter rule RequestSchemaForTrackedResourcesMustHaveTags

A tracked resource MUST always have tags as a top level optional property. Tracked resource does not have tags in the request schema.

Steps to reproduce the behavior:

Expected behavior

The rule should not infer the resource's type (tracked vs proxy) by the presence of a top-level property location.

Instead, it should check whether the resource inherits a common type first, and only if doesn't then fall back to the current logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions