Skip to content

Crash if duplicate model names (across files) used in allOf #479

Open

Description

A TSP conversion PR resulted in this error:

"details":"incompatible properties : tags

definitions/ContainerGroup/properties/tags
 at file:///home/runner/work/azure-rest-api-specs/azure-rest-api-specs/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/ContainerInstance/stable/2025-09-01/containerInstance.json#L2245:8

definitions/Resource/properties/tags
  at file:///home/runner/work/azure-rest-api-specs/azure-rest-api-specs/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/ContainerInstance/stable/2025-09-01/containerInstance.json#L4642:8"

Root cause, oad cannot handle two definitions in different files with the same name, if one definition is used in an allOf:

duplicate-names.json

{
  "swagger": "2.0",
  "info": {
    "title": "duplicate-names",
    "version": "1.0"
  },
  "paths": {},
  "definitions": {
    "Bar": {
      "type": "object",
      "properties": {
        "p1": {
          "type": "string"
        }
      },
      "allOf": [
        {
          "$ref": "./common-types.json#/definitions/Foo"
        }
      ]
    },
    "Foo": {
      "type": "object",
      "properties": {
        "p1": {
          "type": "object"
        }
      }
    }
  }
}

common-types.json

{
  "swagger": "2.0",
  "info": {
    "title": "common-types",
    "version": "1.0"
  },
  "paths": {},
  "definitions": {
    "Foo": {
      "type": "object",
      "properties": {
        "p1": {
          "type": "string"
        }
      }
    }
  }
}

test result

    incompatible properties : p1
      definitions/Bar/properties/p1
        at file:///home/mharder/openapi-diff-mh/incompat-prop/src/test/specs/incompatible-properties/duplicate-names.json#L12:8
      definitions/Foo/properties/p1
        at file:///home/mharder/openapi-diff-mh/incompat-prop/src/test/specs/incompatible-properties/duplicate-names.json#L25:8

Reason, it assumes model names are unique across all files:

private getModelName(ref: string) {
const parts = ref.split("/")
if (parts.length === 3 && parts[1] === "definitions") {
return parts[2]
}
return undefined
}

Related: #347

Activity

  1. changed the title [-]error "incompatible properties" on unrelated types[/-] [+]Crash if spec has two definitions with the same name in two files[/+] on May 5, 2026
  2. changed the title [-]Crash if spec has two definitions with the same name in two files[/-] [+]Crash if spec has two definitions of the same name[/+] on May 5, 2026
  3. changed the title [-]Crash if spec has two definitions of the same name[/-] [+]Crash if spec uses name in allof, and has two definitions of that name in different files[/+] on May 5, 2026
  4. changed the title [-]Crash if spec uses name in allof, and has two definitions of that name in different files[/-] [+]Crash if spec uses name in allOf, and has two definitions of that name in different files[/+] on May 5, 2026
  5. changed the title [-]Crash if spec uses name in allOf, and has two definitions of that name in different files[/-] [+]Crash if duplicate model names (across files) used in allOf[/+] on May 5, 2026
  6. pshao25 commented on May 8, 2026

    @pshao25
    Member

    https://github.com/Azure/azure-rest-api-specs/actions/runs/25541171453 Is this related? I checked the "properties" property, but seems no duplicate.

  7. mikeharder commented on May 8, 2026

    @mikeharder
    ContributorAuthor

    https://github.com/Azure/azure-rest-api-specs/actions/runs/25541171453 Is this related? I checked the "properties" property, but seems no duplicate.

    more likely related to:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions