Repository navigation
fix(aws-codeartifact): close real-cloud parity gaps in #1456 - #1718
Open
thzgajendra wants to merge 2 commits into
Open
thzgajendra wants to merge 2 commits into
thzgajendra wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
aws codeartifact login, publishing a package, permission policies and package groups did not work, and invalid names, a foreign domain owner, a dangling upstream and a second external connection were silently accepted.aws-sdk-go-v2/service/codeartifactv1.45.0, the validation, ownership, upstream and external-connection fixes, package version events on EventBridge, CloudTrail recording, tagging and discovery.Changes
The problem (in plain words)
A developer pointing their tools at cloudemu hits a wall quickly.
aws codeartifact loginfails (GetAuthorizationTokenanswers501 no handler registered),get-repository-endpointanswersunsupported path, and there is no way to publish or read a package, set a permissions policy or create a package group. Worse, the calls that did work were too forgiving:create-repository --repository "bad name"succeeded,--domain-owner 999999999999was ignored, a repository could list a repository that does not exist as its upstream, and a secondassociate-external-connectionsilently replaced the first. A test suite written against cloudemu therefore passed on code that real AWS would reject.How this fixes it
The base
driver.CodeArtifactinterface is unchanged. The new operations arrive as small optional interfaces (Access,Policies,Packages,PackageVersions,PackageGroups, plusRepositoryAdministratorLister) that the wire handler finds by type assertion, as the ECS and Bedrock services already do. All validation, defaults and state rules live in the provider, so the Go library andcloudemu servebehave the same.assetSizeBytescounts identical content once, as AWS stores it once per domain.$,~,*), the most specific match, strong and weak (case or separator variant) matches, inherited modes and allowed-repository lists. A blocked publish is refused.resourceId,resourceTypeandreason. A per-operation IAM resolver (codeartifact:<Operation>, plussts:GetServiceBearerTokenfor the token) makes--enforce-authprecise.CodeArtifact Package Version State Changeevents (documented detail, per-packagesequenceNumber), CloudTrail recording, Resource Groups Tagging discovery and tagging of domains, repositories and package groups, snapshots and--persist(bytes included unless--persist-metadata-only), and a Terraform fixture.Not emulated, and written down in
docs/coverage/nongoals/codeartifact.md: the registry protocols (npm, pip, Maven, ... are not served), ingestion from public registries, request-rate throttling, evaluating resource policies, and the repository state-change event (AWS publishes no payload for it; its reference names it "Goshawk Repository State Change"). A few error choices the AWS reference does not state are chosen conservatively and listed there as unconfirmed.Diagram
flowchart LR C[aws CLI / SDK / Terraform] -->|REST-JSON /v1/...| R[route table: 48 verb + path] R --> H[wire handlers: decode, map errors] H -->|optional capability| P[provider mock: validation, state rules, one lock] P --> S[(domains, repositories, packages, versions, assets, groups, policies)] P -. after unlock .-> E[EventBridge: Package Version State Change] R -. method + path .-> T[CloudTrail event name] P --> D[snapshot / persist]Provider Coverage
Checklist
go test ./...)golangci-lint run --timeout=9m ./...) - 0 issues on the changed CodeArtifact packages; the repo-wide run reports only issues that exist ondevelopmentserver/aws/codeartifact, as in the recent single-service PRs, so nothing was added tocloudemu_test.gogo generate ./...for coverage;go run ./internal/compatgenfor the compat matrix) and committed the resultTest Plan
How I tested it
User environment: macOS (arm64), Go 1.25.0; the repo
Dockerfilebuilt and run with default flags;go install ./cmd/cloudemuwith an empty$HOME; AWS CLI v2.30.0 with an explicit--endpoint-url; boto3 1.43.118 in a fresh venv; OpenTofu v1.13.1 with the realhashicorp/aws ~> 5.0provider and an emptyprovider "aws" {}block; npm; a Go program in a fresh module. Every scenario ran against a build ofstackshy/development(baseline) and this branch. The branch server was built with-race; the race detector reported nothing over the whole session.aws codeartifact login --tool npmwrites the npm config (baseline:501);--dry-runfor pip, twine and swift prints the commands.--unfinished, publish the last asset, list, download (cmpshows identical bytes), archive (download thenConflictException), restore, copy twice (ALREADY_EXISTS), dispose, delete versions, delete package. Baseline:501for all of it.No changes, update in place, re-planNo changes,importof repository and domain by ARN, destroy. On the baseline the same project fails atPutRepositoryPermissionsPolicywith404 ResourceNotFoundException. The repo's owncontrib/terraformfixturecodeartifactpasses too.--domain-ownerignored, dangling upstream accepted, second external connection replaced the first, deleting an upstream accepted,max-results=0accepted. Branch:ValidationException,ResourceNotFoundException,ResourceNotFoundException,ConflictException(first connection kept),ConflictException,ValidationException.405and 12404from the S3 fall-through, 7unsupported path); on the branch every one is answered by CodeArtifact.ServiceQuotaExceededException 402, listing walks 10 pages of 100), 10 upstreams (11th refused), 200 tags (201st refused, overwrite at the limit fine), 350 assets per version, an asset of exactly 128 MiB accepted and 128 MiB + 1 byte refused, name boundaries (2 and 50 characters for domains, 2 and 100 for repositories).create-domainof one name: exactly one succeeds. 40 parallel creates against the 10-domain quota: 10 domains. 40 parallel publishes, status updates racingdelete-package, and publishes racingdelete-repository: nothing resurrected, 0 orphan bytes.--persistrestart: revision, asset bytes, policies, groups and tags survive; state written by the baseline binary loads in this binary;--persist-metadata-onlykeeps structure but not bytes; snapshot, rewind and fork restore bytes.--enforce-authwith seeded IAM users: a read-only user reads and downloads but every write answersAccessDeniedException; a user allowed onlyDescribeRepositoryon one repository sees only that repository;get-authorization-tokenneeds thestsaction as well. S3 and SQS keep working. A copy needscodeartifact:ReadFromRepositoryon the source repository as well as write access to the destination: a user with only the destination permission is denied and nothing is copied.aws.codeartifactto an SQS queue: publish, archive and delete deliver three events with the documented envelope and detail. CloudTraillookup-eventslists the calls fromcodeartifact.amazonaws.com.New tests (all in
providers/aws/codeartifactandserver/aws/codeartifactunless noted), red ondevelopmentand green here for the regression rows: name and owner patterns, ownership on lookups, upstream rules (dangling, self, duplicate, cycle, 10 maximum, XOR with an external connection), the ten external connection names, delete guards, tag limit at 200/201, policy revision lock, publish and status state machine, copy, dispose, origin controls, group grammar (every pattern in the AWS user guide), hierarchy and strong/weak matching, events, snapshot round trip, pagination of every list; race tests for the domain, repository, tag, upstream, asset and group invariants, policy revision compare-and-set, create-vs-delete orphans and aliasing; real-SDK round trips; a 48-operation route and model check (testdata/operations.jsonfrom the botocore model) and an error-matrix test that drives every operation into a validation error and a not-found error and checks each exception is one the model lists for that operation; IAM resolver tests;TestRecordsCodeArtifactEvents(CloudTrail),TestCodeArtifactPackageVersionEvents(EventBridge to SQS),TestCodeArtifactDiscoveryAndTaggingandTestCodeArtifactWinsBeforeS3AndLeavesSiblingsAlone(routing seam).Library API.
driver.CodeArtifactis unchanged. Added:driver.Access,Policies,Packages,PackageVersions,PackageGroups,RepositoryAdministratorLister,APIErrorfieldsResourceID,ResourceType,Reason,ExServiceQuota, and resource type and format constants. Existing methods now return typed errors for input they used to accept (invalid names, a foreign domain owner, dangling upstreams), which is the behaviour change #1456 asks for.Coverage
providers/aws/codeartifact81.6% -> 94.4%;server/aws/codeartifact69.4% -> 95.1%; every function added is exercised by a test. The local CI gate (build, vet,go test ./...,-raceon touched packages,go mod tidy -diff, golangci-lint on new lines,go generateandcompatgendrift, Structure, contrib modules) passes.Related Issues
Closes #1456