From 2f8818b32cb1b465cd83b9700fed5fc12d64f39e Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 09:05:44 +0200 Subject: [PATCH] fix(contract): file-specific certification response component names; guard against same-name components with different bodies Co-Authored-By: Claude Sonnet 5.5 --- ...fication-response-component-names.fixed.md | 1 + parity/python-js-sdk.json | 2 +- tests/test_component_name_collisions.py | 42 +++++++++++++++++++ .../certificate_build_sessions_endpoints.json | 32 +++++++------- .../process_records_endpoints.json | 36 ++++++++-------- 5 files changed, 78 insertions(+), 35 deletions(-) create mode 100644 changelog.d/certification-response-component-names.fixed.md create mode 100644 tests/test_component_name_collisions.py diff --git a/changelog.d/certification-response-component-names.fixed.md b/changelog.d/certification-response-component-names.fixed.md new file mode 100644 index 00000000..3e477f33 --- /dev/null +++ b/changelog.d/certification-response-component-names.fixed.md @@ -0,0 +1 @@ +- The certification build-session and process-record contract files now use file-specific response component names, so they no longer clash with the existing certification contract's components; wire bodies are unchanged. diff --git a/parity/python-js-sdk.json b/parity/python-js-sdk.json index 4715c5bc..04060676 100644 --- a/parity/python-js-sdk.json +++ b/parity/python-js-sdk.json @@ -399,7 +399,7 @@ "sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket." }, "schemaRefresh": { - "lastSchemaFileSha": "a11b5e0ef9452b8e847b70cab387f0172c442b0446a5c4dee2bf504086ee3ffc", + "lastSchemaFileSha": "e1336def76c4e9122fd14a4a4ccd8abb370e7a196a93fabecfabba6e270290c4", "schemaFileCount": 692, "note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block." } diff --git a/tests/test_component_name_collisions.py b/tests/test_component_name_collisions.py new file mode 100644 index 00000000..3cf622c9 --- /dev/null +++ b/tests/test_component_name_collisions.py @@ -0,0 +1,42 @@ +"""No OpenAPI component name is defined twice with different bodies. + +Consumers merge the ``components`` sections of every schema file into one +document; the same name with two different bodies makes that merge fail. +""" + +from __future__ import annotations + +import json +from collections import defaultdict + +from traigent_schema.utils import get_schemas_dir + + +def _canonical(body: object) -> str: + return json.dumps(body, sort_keys=True, separators=(",", ":")) + + +def test_same_named_components_have_identical_bodies(): + root = get_schemas_dir() + seen: dict[tuple[str, str], dict[str, set[str]]] = defaultdict( + lambda: defaultdict(set) + ) + for path in sorted(root.rglob("*.json")): + data = json.loads(path.read_text(encoding="utf-8")) + components = data.get("components") if isinstance(data, dict) else None + if not isinstance(components, dict): + continue + rel = path.relative_to(root).as_posix() + for section, entries in components.items(): + if not isinstance(entries, dict): + continue + for name, body in entries.items(): + seen[(section, name)][_canonical(body)].add(rel) + + conflicts = [ + f"{section}/{name}: " + + " vs ".join(sorted("+".join(sorted(f)) for f in bodies.values())) + for (section, name), bodies in sorted(seen.items()) + if len(bodies) > 1 + ] + assert not conflicts, "component name collisions:\n" + "\n".join(conflicts) diff --git a/traigent_schema/schemas/certification/certificate_build_sessions_endpoints.json b/traigent_schema/schemas/certification/certificate_build_sessions_endpoints.json index 2bbff9db..aaf63a3f 100644 --- a/traigent_schema/schemas/certification/certificate_build_sessions_endpoints.json +++ b/traigent_schema/schemas/certification/certificate_build_sessions_endpoints.json @@ -42,12 +42,12 @@ } } }, - "400": {"$ref": "#/components/responses/BadRequest"}, - "401": {"$ref": "#/components/responses/Unauthorized"}, - "403": {"$ref": "#/components/responses/Forbidden"}, - "404": {"$ref": "#/components/responses/NotFound"}, - "409": {"$ref": "#/components/responses/Conflict"}, - "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "400": {"$ref": "#/components/responses/CertificateBuildSessionBadRequest"}, + "401": {"$ref": "#/components/responses/CertificateBuildSessionUnauthorized"}, + "403": {"$ref": "#/components/responses/CertificateBuildSessionForbidden"}, + "404": {"$ref": "#/components/responses/CertificateBuildSessionNotFound"}, + "409": {"$ref": "#/components/responses/CertificateBuildSessionConflict"}, + "413": {"$ref": "#/components/responses/CertificateBuildSessionPayloadTooLarge"}, "422": {"$ref": "#/components/responses/Unprocessable"}, "429": {"$ref": "#/components/responses/RateLimited"}, "500": {"$ref": "#/components/responses/AuthenticationError"}, @@ -99,10 +99,10 @@ } }, "400": {"$ref": "#/components/responses/ProviderCredentialRejected"}, - "401": {"$ref": "#/components/responses/Unauthorized"}, - "403": {"$ref": "#/components/responses/Forbidden"}, - "404": {"$ref": "#/components/responses/NotFound"}, - "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "401": {"$ref": "#/components/responses/CertificateBuildSessionUnauthorized"}, + "403": {"$ref": "#/components/responses/CertificateBuildSessionForbidden"}, + "404": {"$ref": "#/components/responses/CertificateBuildSessionNotFound"}, + "413": {"$ref": "#/components/responses/CertificateBuildSessionPayloadTooLarge"}, "422": {"$ref": "#/components/responses/Unprocessable"}, "429": {"$ref": "#/components/responses/RateLimited"}, "500": {"$ref": "#/components/responses/AuthenticationError"}, @@ -116,7 +116,7 @@ }, "components": { "responses": { - "PayloadTooLarge": { + "CertificateBuildSessionPayloadTooLarge": { "description": "The request exceeds the size limit.", "content": { "application/json": { @@ -141,7 +141,7 @@ "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/Unprocessable"}} } }, - "BadRequest": { + "CertificateBuildSessionBadRequest": { "description": "Invalid build-session reference, unsupported content type, or provider credential rejected.", "content": { "application/json": { @@ -161,7 +161,7 @@ "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} } }, - "Unauthorized": { + "CertificateBuildSessionUnauthorized": { "description": "Authentication required.", "content": { "application/json": { @@ -174,7 +174,7 @@ } } }, - "Forbidden": { + "CertificateBuildSessionForbidden": { "description": "Authorization denied.", "content": { "application/json": { @@ -188,7 +188,7 @@ } } }, - "NotFound": { + "CertificateBuildSessionNotFound": { "description": "The project or build session was not found, or the route is unavailable.", "content": {"application/json": {"schema": { "anyOf": [ @@ -199,7 +199,7 @@ ] }}} }, - "Conflict": { + "CertificateBuildSessionConflict": { "description": "The issuance state conflicts with abandonment.", "content": {"application/json": {"schema": {"$ref": "./certificate_error_v0_schema.json#/definitions/StateConflictV0"}}} }, diff --git a/traigent_schema/schemas/certification/process_records_endpoints.json b/traigent_schema/schemas/certification/process_records_endpoints.json index 43d69180..7e18fc5f 100644 --- a/traigent_schema/schemas/certification/process_records_endpoints.json +++ b/traigent_schema/schemas/certification/process_records_endpoints.json @@ -81,17 +81,17 @@ "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} } }, - "401": {"$ref": "#/components/responses/Unauthorized"}, + "401": {"$ref": "#/components/responses/ProcessRecordUnauthorized"}, "403": {"$ref": "#/components/responses/WriteForbidden"}, - "404": {"$ref": "#/components/responses/NotFound"}, + "404": {"$ref": "#/components/responses/ProcessRecordNotFound"}, "422": {"$ref": "#/components/responses/Unprocessable"}, "409": { "description": "The requested receipt snapshot conflicts with current state.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordConflict"}}} }, - "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "413": {"$ref": "#/components/responses/ProcessRecordPayloadTooLarge"}, "429": {"$ref": "#/components/responses/RateLimited"}, - "500": {"$ref": "#/components/responses/InternalError"}, + "500": {"$ref": "#/components/responses/ProcessRecordInternalError"}, "503": { "description": "Receipt or authentication data is temporarily unavailable.", "content": { @@ -193,7 +193,7 @@ "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} } }, - "401": {"$ref": "#/components/responses/Unauthorized"}, + "401": {"$ref": "#/components/responses/ProcessRecordUnauthorized"}, "403": { "description": "The caller lacks read access to the project.", "content": { @@ -323,9 +323,9 @@ } } }, - "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "413": {"$ref": "#/components/responses/ProcessRecordPayloadTooLarge"}, "429": {"$ref": "#/components/responses/RateLimited"}, - "500": {"$ref": "#/components/responses/InternalError"}, + "500": {"$ref": "#/components/responses/ProcessRecordInternalError"}, "503": { "description": "The stored issuance could not be read or reconciled.", "content": { @@ -507,9 +507,9 @@ "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} } }, - "401": {"$ref": "#/components/responses/Unauthorized"}, + "401": {"$ref": "#/components/responses/ProcessRecordUnauthorized"}, "403": {"$ref": "#/components/responses/WriteForbidden"}, - "404": {"$ref": "#/components/responses/NotFound"}, + "404": {"$ref": "#/components/responses/ProcessRecordNotFound"}, "409": { "description": "Issuance conflicts with current state. A retry delay is returned when issuance is already in progress.", "headers": { @@ -646,9 +646,9 @@ } } }, - "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "413": {"$ref": "#/components/responses/ProcessRecordPayloadTooLarge"}, "429": {"$ref": "#/components/responses/RateLimited"}, - "500": {"$ref": "#/components/responses/InternalError"}, + "500": {"$ref": "#/components/responses/ProcessRecordInternalError"}, "503": { "description": "Issuance could not be completed or confirmed.", "content": { @@ -774,7 +774,7 @@ "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} } }, - "401": {"$ref": "#/components/responses/Unauthorized"}, + "401": {"$ref": "#/components/responses/ProcessRecordUnauthorized"}, "403": { "description": "The caller lacks read access.", "content": { @@ -853,9 +853,9 @@ } } }, - "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "413": {"$ref": "#/components/responses/ProcessRecordPayloadTooLarge"}, "429": {"$ref": "#/components/responses/RateLimited"}, - "500": {"$ref": "#/components/responses/InternalError"}, + "500": {"$ref": "#/components/responses/ProcessRecordInternalError"}, "503": { "description": "Authentication is temporarily unavailable.", "content": { @@ -885,7 +885,7 @@ }, "components": { "responses": { - "PayloadTooLarge": { + "ProcessRecordPayloadTooLarge": { "description": "The request exceeds the size limit.", "content": { "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/RequestTooLarge"}} @@ -903,7 +903,7 @@ "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/Unprocessable"}} } }, - "Unauthorized": { + "ProcessRecordUnauthorized": { "description": "Authentication required.", "content": { "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/Unauthorized"}} @@ -913,11 +913,11 @@ "description": "The caller lacks write access to the project.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordWriteForbidden"}}} }, - "NotFound": { + "ProcessRecordNotFound": { "description": "No accessible matching scope was found. The code LINEAGE_UNMAPPED means the build session reference is valid but the build session is not yet finalized, so it does not resolve to an issuance; finalize the build session and retry.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordScopeNotFound"}}} }, - "InternalError": { + "ProcessRecordInternalError": { "description": "An unexpected server error occurred.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordInternal"}}} }