fix(codeartifact): populate resourceId/resourceType on error responses (#3977)

Every ConflictException, ResourceNotFoundException, and ServiceQuotaExceededException
the service threw carried a message only, but the wire model declares
resourceId/resourceType on all three, and the AWS SDK exposes them as typed
accessors. Populate them consistently using the resource's locally-unique name
(domain name, repository name, package version, or asset name) as resourceId.

Populating resourceId this way exposed a real crash: Map.of() rejects null
values, so any request missing a required identifier (domain, repository,
package, packageVersion, asset) turned what used to be a wrong-status
ResourceNotFoundException into a raw NullPointerException / HTTP 500. Fixed
by validating required identifiers up front (returning ValidationException,
matching AWS) and by making the extendedData-building helper itself
null-safe against a missing resourceId, so no single overlooked call site
can reintroduce a 500.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-20 09:13:46 -05:00
1 parent 7c6cb265dc
commit 2697868e86
5 files changed
+265 -69

No files matched your search

@@ -78,7 +78,10 @@ class CodeArtifactTest {
@DisplayName("CreateDomain - duplicate returns ConflictException")
void createDomainDuplicateFails() {
assertThatThrownBy(() -> codeArtifact.createDomain(r -> r.domain(DOMAIN)))
.isInstanceOf(ConflictException.class);
.isInstanceOfSatisfying(ConflictException.class, e -> {
assertThat(e.resourceId()).isEqualTo(DOMAIN);
assertThat(e.resourceTypeAsString()).isEqualTo("domain");
});
}
@Test
@@ -88,7 +91,10 @@ class CodeArtifactTest {
assertThatThrownBy(() -> codeArtifact.createRepository(r -> r
.domain("does-not-exist-domain")
.repository(REPO)))
.isInstanceOf(ResourceNotFoundException.class);
.isInstanceOfSatisfying(ResourceNotFoundException.class, e -> {
assertThat(e.resourceId()).isEqualTo("does-not-exist-domain");
assertThat(e.resourceTypeAsString()).isEqualTo("domain");
});
}
@Test