Skip to content

Harden Rule 29 duplicate-schema fingerprinting to avoid false positives#740

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-false-positives-in-duplicate-schema-fingerprin
Draft

Harden Rule 29 duplicate-schema fingerprinting to avoid false positives#740
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-false-positives-in-duplicate-schema-fingerprin

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Rule 29 was over-collapsing structurally similar schemas by fingerprinting only coarse property/type shape. That caused false duplicate matches when schemas differed in $ref targets, required fields, constraints, or descriptions.

  • Fingerprint normalization

    • Extract Rule 29 fingerprinting into a dedicated helper: build/lib/duplicate-schema-fingerprint.js
    • Fingerprints now include:
      • full $ref paths
      • sorted required arrays
      • property and schema description
      • validation constraints such as minLength, maxLength, pattern, minimum, maximum, and related bounds
      • nested schema structure in items, additionalProperties, and allOf / anyOf / oneOf
  • Validator wiring

    • Replace the previous inline Rule 29 fingerprint function in build/validate-schemas.js
    • Preserve deterministic matching for semantically equivalent schemas by sorting property keys and required entries
  • Focused regression coverage

    • Add tests/validate-schemas-duplicate-schema-fingerprint.test.js
    • Cover cases where fingerprints must now diverge:
      • different full $ref paths
      • different required sets
      • different constraints
      • different descriptions
    • Also cover the non-regression case where equivalent schemas with reordered fields still fingerprint identically
const schemaA = {
  type: "object",
  required: ["name", "id"],
  properties: {
    id: { $ref: "../../v1alpha1/core/api.yml#/components/schemas/uuid" },
    name: { type: "string", minLength: 1, description: "Display name." },
    created_at: { type: "string", format: "date-time" },
  },
};

const schemaB = {
  ...schemaA,
  properties: {
    ...schemaA.properties,
    id: { $ref: "../../v1beta1/core/api.yml#/components/schemas/uuid" },
  },
};

// Previously could collide; now fingerprints differ because the full $ref path differs.

Agent-Logs-Url: https://github.com/meshery/schemas/sessions/3570a193-0d21-4281-9b0e-33a5b1793b46

Co-authored-by: yi-nuo426 <218099172+yi-nuo426@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix false positives in duplicate schema fingerprinting for Rule 29 Harden Rule 29 duplicate-schema fingerprinting to avoid false positives Apr 8, 2026
Copilot AI requested a review from yi-nuo426 April 8, 2026 04:35
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.

Validator: fix false positives in duplicate schema fingerprinting (Rule 29)

2 participants