Skip to content

fix: strip source-service tagId from ApiTagDescription PUT payloads - #313

Merged
Alexander Zaslonov (azaslonov) merged 2 commits into
Azure:mainfrom
Alexey-Zheltov:fix/tagdescription-strip-tagid
Oct 10, 2026
Merged

Alexander Zaslonov (azaslonov) merged 2 commits into
Azure:mainfrom
Alexey-Zheltov:fix/tagdescription-strip-tagid

Conversation

@Alexey-Zheltov

Copy link
Copy Markdown
Collaborator

Summary

Cross-service publish fails on every ApiTagDescription with HTTP 400 ValidationError: Cross-service resource references are not allowed. Extracted tagDescriptionInformation.json carries properties.tagId with the full ARM path of the source service's tag, and the publisher sent the body verbatim; newer APIM api-versions validate ARM references in PUT bodies.

Per the ARM contract (TagDescriptionCreateParameters), tagId is response-only — the tag is identified by the request URL (.../apis/{apiId}/tagDescriptions/{tagDescriptionId}) — so this PR strips it from the PUT payload. Same bug family as #285 (top-level id, diagnostic loggerId), which missed this field.

Changes

  • src/services/resource-publisher.ts: new stripTagDescriptionTagId() dropping properties.tagId; wired into publishResource for ResourceType.ApiTagDescription
  • tests/unit/services/resource-publisher.test.ts: 3 unit tests (strips source-service tagId while keeping other properties; no-op when tagId or properties absent)

Related Issue(s)

Closes #312

Testing

  • npx vitest run tests/unit/services/resource-publisher.test.ts — 84/84 passed
  • Reproduced originally publishing artifacts extracted from one APIM service to another; the apitagdescription PUTs were the only remaining cross-service failures

Code Review

Code review requested per repository ceremony (changes under src/ and tests/).

Copilot AI balanced review requested due to automatic review settings October 5, 2026 12:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The tests do not verify that publishResource applies the transformation to the outgoing payload.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Strips source-service tagId values from API tag-description PUT payloads.

Changes:

  • Adds and wires stripTagDescriptionTagId.
  • Adds unit tests for transformation behavior.
File Description
src/​services/​resource-publisher.ts Removes properties.tagId before publishing tag descriptions.
tests/​unit/​services/​resource-publisher.test.ts Tests the new payload helper.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Extracted tagDescriptionInformation.json carries properties.tagId with the
full ARM path of the SOURCE service's tag. Newer APIM api-versions validate
ARM references in PUT bodies and reject cross-service publishes with
"Cross-service resource references are not allowed". tagId is response-only
per the ARM contract (the tag is identified by the request URL), so drop it
before PUT. Same bug family as the top-level id / diagnostic loggerId fixes.

Closes Azure#312
Copilot AI balanced review requested due to automatic review settings October 5, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused fix matches the API contract and is adequately covered by unit tests.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Aleksey Zheltov (Alexey-Zheltov) added a commit to Alexey-Zheltov/apiops-cli that referenced this pull request Oct 9, 2026
Addresses review feedback on Azure#313: the helper-level tests alone would not
catch a broken or mistyped dispatch condition in publishResource. The new
test drives publishResource with an ApiTagDescription descriptor and asserts
the payload handed to client.putResource carries no properties.tagId.

Fix verified against a live APIM instance: cross-service publish of an API
with three tag descriptions succeeded and APIM re-derived tagId against the
target service.
Copilot AI balanced review requested due to automatic review settings October 9, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The added WebSocket skip test fails because its asserted production behavior is not implemented.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Addresses review feedback on Azure#313: the helper-level tests alone would not
catch a broken or mistyped dispatch condition in publishResource. The new
test drives publishResource with an ApiTagDescription descriptor and asserts
the payload handed to client.putResource carries no properties.tagId.

Fix verified against a live APIM instance: cross-service publish of an API
with three tag descriptions succeeded and APIM re-derived tagId against the
target service.
Copilot AI balanced review requested due to automatic review settings October 9, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The targeted normalization is correctly integrated and adequately tested without affecting unrelated resources.

1 open finding

🧠 Review effort: Balanced

@azaslonov
Alexander Zaslonov (azaslonov) merged commit 88a29b2 into Azure:main Oct 10, 2026
6 checks passed
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.

publish: ApiTagDescription PUT fails cross-service — properties.tagId references source APIM service

4 participants