Context
Follow-on from #132 (multi-environment publish to shared APIM). Surfaced during ApimExpert domain review.
The environment: block validator in src/services/env-mapping-validator.ts correctly checks affix characters ([A-Za-z0-9-] only) but does not validate that namePrefix + canonicalName + nameSuffix stays within APIM's per-type name limits (80 characters for APIs, NamedValues, and most other top-level resources).
Problem
A user with a long organizational prefix and a long canonical name can produce a deployed name that exceeds APIM's limit. The failure surfaces as a cryptic HTTP 400 from the ARM API mid-publish, with no clear indication that the affix is the cause.
Example (hypothetical):
namePrefix: "production-us-east-" (19 chars)
- Canonical name:
"enterprise-billing-reconciliation-api" (37 chars)
nameSuffix: "-v2-stable" (10 chars)
- Combined: 66 chars — safe. But narrower margins exist.
Proposed fix
After the existing character-validity check in validateAndBuildEnvMapping, iterate over artifactDescriptors and warn (not error — warn) when a combined name would exceed 80 characters. The data is already in scope:
for (const d of artifactDescriptors) {
if (d.nameParts.length > 0 && mapping.appliesTo.has(d.type)) {
const deployedLen = prefix.length + d.nameParts[0]!.length + suffix.length;
if (deployedLen > 80) {
logger.warn(
`[publish] Affixed name "${prefix}${d.nameParts[0]}${suffix}" would be ${deployedLen} chars, ` +
`exceeding APIM's 80-character resource name limit for ${d.type}.`
);
}
}
}
Acceptance criteria
Not doing
- Not promoting to a hard error — some resource types may tolerate longer names, and users can still publish successfully in some scenarios.
- Not attempting to truncate or transform names automatically.
Context
Follow-on from #132 (multi-environment publish to shared APIM). Surfaced during ApimExpert domain review.
The
environment:block validator insrc/services/env-mapping-validator.tscorrectly checks affix characters ([A-Za-z0-9-]only) but does not validate thatnamePrefix + canonicalName + nameSuffixstays within APIM's per-type name limits (80 characters for APIs, NamedValues, and most other top-level resources).Problem
A user with a long organizational prefix and a long canonical name can produce a deployed name that exceeds APIM's limit. The failure surfaces as a cryptic HTTP 400 from the ARM API mid-publish, with no clear indication that the affix is the cause.
Example (hypothetical):
namePrefix: "production-us-east-"(19 chars)"enterprise-billing-reconciliation-api"(37 chars)nameSuffix: "-v2-stable"(10 chars)Proposed fix
After the existing character-validity check in
validateAndBuildEnvMapping, iterate overartifactDescriptorsand warn (not error — warn) when a combined name would exceed 80 characters. The data is already in scope:Acceptance criteria
Not doing