Skip to content

fix: normalize subscription ownerId to relative /users path on publish - #279

Merged
Alexander Zaslonov (azaslonov) merged 1 commit into
Azure:mainfrom
Alexey-Zheltov:fix/subscription-ownerid-normalization
Sep 12, 2026
Merged

fix: normalize subscription ownerId to relative /users path on publish#279
Alexander Zaslonov (azaslonov) merged 1 commit into
Azure:mainfrom
Alexey-Zheltov:fix/subscription-ownerid-normalization

Conversation

@Alexey-Zheltov

Copy link
Copy Markdown
Collaborator

Summary

Normalizes properties.ownerId of Subscription resources on publish, mirroring the existing scope normalization.

APIM returns ownerId as a full ARM resource path on GET (carrying the source service coordinates), but the PUT endpoint expects a relative URL in the format /users/{userId}. Previously a subscription extracted from one instance and published to another carried the source instance's ownerId unchanged.

  • New normalizeSubscriptionOwnerId() sibling of normalizeSubscriptionScope(), applied in the Subscription branch of publishResource
  • Strips the service ARM prefix: .../service/{src-svc}/users/1/users/1
  • envMapping affixes are deliberately NOT applied — a user id is not an affixed resource name
  • Already-relative values pass through unchanged

Related Issue(s)

Closes #273

Verification

  • 3 new unit tests (absolute → relative, already-relative untouched, envMapping affixes scope but not ownerId)
  • tests/unit/services/resource-publisher.test.ts: 77/77 pass
  • tsc --noEmit clean

APIM returns ownerId as a full ARM resource path on GET, carrying the
source service coordinates. The PUT endpoint expects a relative URL in
the format /users/{userId}, so cross-instance publishes sent an ownerId
naming the source service. Strip the service ARM prefix the same way
normalizeSubscriptionScope handles scope. envMapping affixes are not
applied (a user id is not an affixed resource name); already-relative
values pass through unchanged.

Closes Azure#273
Copilot AI balanced review requested due to automatic review settings September 11, 2026 16:40

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

No unresolved blocking issues were identified, and the normalization cases are covered by tests.

Pull request overview

Normalizes Subscription ownerId values to relative /users/{userId} paths when publishing across APIM instances.

Changes:

  • Added owner ID normalization during subscription publishing.
  • Preserved relative IDs and excluded environment-mapping affixes.
  • Added three unit tests covering the behavior.
File summaries
File Summary
tests/unit/services/resource-publisher.test.ts Tests absolute, relative, and environment-mapping owner IDs.
src/services/resource-publisher.ts Normalizes Subscription owner IDs before publishing.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.


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

@azaslonov
Alexander Zaslonov (azaslonov) merged commit afb5a7d into Azure:main Sep 12, 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.

Subscription ownerId is not normalized on publish, unlike scope

3 participants