Skip to content

fix(#1123): a deployed resource that failed is not a deployed resource - #1257

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1123-cfn-deploy-assertions
Sep 20, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1123-cfn-deploy-assertions

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

StackDeployer.Deploy reports a resource it could not create on that resource's own
DeployedResource.Error and returns no Go error. So the pair of assertions a CloudFormation test
reaches for by default — require.NoError(t, err) and result != nil — is satisfied by a template in
which every resource was refused.

TestCFN_AppSyncFullStack was exactly that. It named its API by {"Ref": "MyAPI"}, which resolves to
the API's ARN — what AWS::AppSync::GraphQLApi's Return values section publishes, and what #837
made substrate answer — so all three child resources addressed
/v1/apis/arn:aws:appsync:us-east-1:123456789012:apis/<id>/datasources and were refused
UnknownOperationException. The stack reached ROLLBACK_COMPLETE. The test was green.

What changed

Both AppSync CloudFormation tests now name the API by {"Fn::GetAtt": ["MyAPI", "ApiId"]}, the form
AWS's own page documents, and assert each deployed resource's error, physical ID and ARN rather than
only that the result is non-nil.

requireDeployedCleanly(t, result, wantResources) sits beside newTestDeployer, so a new
CloudFormation test gets the per-resource assertion by default. It checks the stack's status as well,
because a failed resource and the rollback it triggers are two observations of one event and a caller
may reach either first.

The sweep

All 305 tests that call Deploy were run individually against an instrumented failed-resource
path. Individually because the package has 1464 t.Parallel() calls, which make stderr attribution
from one whole-suite run wrong — that variant mis-attributed 91 lines across 64 names against a true
34.

34 deploy a failing resource. Most are deliberate: a test whose subject is a refusal. Five were
asserting something they could not observe:

Test What was wrong
TestCFN_AppSyncFullStack three resources refused; Ref instead of Fn::GetAtt ApiId
TestCFN_ChangeSet_CreateDescribeExecute added an AWS::SNS::Topic its deployer registers no plugin for
TestCFN_MultiKeyMapIsNotAnIntrinsic one bucket name across 20 iterations
TestCFN_AppSync{DataSourceMissingApiId,ResolverMissingFields,FunctionMissingApiId} asserted only result != nil

TestCFN_ChangeSet_CreateDescribeExecute: executing the change set refused the topic with
ServiceNotAvailable, rolled the update back by re-deploying the first template, and refused the IAM
role with EntityAlreadyExists on the way — ending in UPDATE_ROLLBACK_FAILED with
assert.NotNil(t, result) holding throughout. It now adds an AWS::SQS::Queue, the same shape of
change against a service the deployer can reach, and asserts the update clean.

TestCFN_MultiKeyMapIsNotAnIntrinsic is the sharpest of them. 19 of its 20 iterations were refused
BucketAlreadyExists and rolled back, and a rolled-back stack has no outputs — so
result.Outputs["Both"] was "", which satisfies both assert.NotEqual calls. The repetition that
exists to catch a map-iteration race asserted nothing from the second iteration on. The bucket name
now carries the iteration, and the output is asserted exactly ({"Fn::Sub":"also-${P}","Ref":"P"})
rather than only as "neither intrinsic" — encoding/json orders a map's keys, so byte-for-byte
equality across 20 runs is the determinism claim the test is actually about.

The three AppSync refusal tests now assert the refusal they are named for, including that a resource
that was never created carries no ARN.

Route 53, and why it is not fixed here

TestCFN_Route53RecordSetGroup fails for a production reason: Ref on a hosted zone answers the
/hostedzone/Z… path form CreateHostedZone returns, where the CloudFormation page publishes the
bare ID, so a record set naming its zone the way AWS's examples do builds
POST /2013-04-01/hostedzone//hostedzone/Z…/rrset and is refused InvalidAction. Separately,
deployRoute53RecordSetGroup keeps only the Go error from each child, and a refusal is not one, so
the group reports a clean resource while every record set under it was refused.

That is filed as #1256, because this issue's last acceptance criterion predicted no production
change. The test is given the per-resource assertion it was missing, pinning today's refusal with a
TODO(#1256), so fixing #1256 turns this test red rather than leaving it silently green in either
state.

Verification

Non-vacuity was checked by keeping the new assertions and reverting only the template fixes:

  • Fn::GetAtt → Ref: Should be empty, but was UnknownOperationException: … /datasources is not recognized, three times, plus "ROLLBACK_COMPLETE" should not contain "ROLLBACK".
  • queue → topic: Should be empty, but was EntityAlreadyExists: Role with name cs-test-role already exists. and "UPDATE_ROLLBACK_FAILED" should not contain "FAILED".
  • per-iteration bucket name → shared: Should be empty, but was BucketAlreadyExists and
    map[string]string{} does not contain "Both" — the vacuity, stated by the test runner.

make lint 0 issues; make test green with the race detector; docs-reference-check,
docs-versions, version-check, discarded-unmarshal-check and wire-bookkeeping-check all pass.

Compatibility

No production code changes. docs/services.md's AppSync CloudFormation section is updated — the
sentence recording that substrate's own tests used the Ref form is now the statement that they use
Fn::GetAtt and assert every resource.

Closes #1123

StackDeployer.Deploy reports a refusal on the resource's own DeployedResource.Error
and returns no Go error, so `require.NoError` plus `result != nil` passes for a
template in which nothing was created. TestCFN_AppSyncFullStack was that: `Ref` on
a GraphQLApi is the API's ARN, so all three children addressed
/v1/apis/arn:aws:appsync:.../datasources and were refused.

Both AppSync CFN tests now name the API by Fn::GetAtt ApiId, the form the page
documents, and assert each resource's error, physical ID and ARN. A sweep ran the
305 Deploy-calling tests individually against an instrumented failed-resource
path — individually because 1464 t.Parallel() calls make whole-suite attribution
wrong — and found 34 deploying a failing resource, five of them asserting
something unobservable:

- TestCFN_ChangeSet_CreateDescribeExecute added an SNS topic its deployer has no
  plugin for, ending in UPDATE_ROLLBACK_FAILED; it adds a queue now.
- TestCFN_MultiKeyMapIsNotAnIntrinsic reused one bucket name across 20
  iterations, so 19 rolled back and an empty Outputs satisfied both NotEquals.
- The three AppSync refusal tests asserted only `result != nil`.

requireDeployedCleanly sits beside newTestDeployer so a new test gets the
per-resource assertion by default. TestCFN_Route53RecordSetGroup fails for a
production reason, filed as #1256; its refusal is pinned so fixing #1256 turns
the test red rather than leaving it green either way.

No production behaviour changes.

Closes #1123
@codecov

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 8744220 into main Sep 20, 2026
18 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1123-cfn-deploy-assertions branch September 20, 2026 09:22
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.

TestCFN_AppSyncFullStack deploys three resources that all fail, and passes

1 participant