Skip to content

fix(dns): surface DNS registration failures instead of swallowing them (#435, #434) - #436

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/435-dns-registration-visibility
Jul 23, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/435-dns-registration-visibility

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Addresses #435 (DNS registration silently broken post-AWS_IAM cutover) and #434 (stale base36 doc example).

#435 — the failure was invisible

After the #173 AuthType: AWS_IAM cutover, spored's DNS registration is rejected with a 403 at the Function URL auth layer (0 Lambda invocations). Three things hid it:

  1. pkg/dns/client.go swallowed non-2xx. It never checked resp.StatusCode — it parsed the 403 body ({"Message":"Forbidden"}) straight into a DNSUpdateResponse, which unmarshals to all-empty (Success=false, Error=""), producing a useless DNS API error: (empty). Now it checks the status and surfaces HTTP 403: <body snippet>.
  2. spored only logged to its own journal. The launching user never sees Warning: Failed to register DNS. spored now records spawn:dns-status (registered/failed) and spawn:dns-error as instance tags (best-effort, throttle/deny-tolerant, mirroring the existing spawn:ready-status pattern).
  3. spawn status said nothing. It now prints a clear warning when spawn:dns-status=failed, naming the cause — so "the FQDN never resolves" is diagnosable from the launch account.

Tests: TestCallAPI_ForbiddenNotSwallowed (httptest 403) and TestDNSStatusNotice (table).

Root cause status (still open)

This PR makes the failure visible; it does not yet fix the underlying 403. I verified read-only that the infra side is correct — the Function URL is AuthType: AWS_IAM and the Lambda's resource policy (FunctionURLAllowIAMAccess, Principal:*, FunctionUrlAuthType: AWS_IAM condition) does allow cross-account IAM callers, and the dev instance role grants lambda:InvokeFunctionUrl. So it's a signature/credential-level rejection, not a missing policy. The signing code (signRequest, SigV4 lambda service) also has passing unit tests. Continuing to root-cause on #435.

#434 — stale base36 example (doc-only)

123456789012 encodes to 1kpqzg2c (≤8 chars), not the 1s69p4h (7 chars) in the pkg/dns/encoding.go doc comment. Verified with Go's big.Int.Text(36); the code was always correct and the sibling Lambda already had the right value. Fixed the comment in both files (incl. the misleading "(7 chars)").

Notes

  • lambda/dns-updater is a separate Go module; both build clean.
  • Pre-existing unrelated failure TestCatalogValid Correction: TestCatalogValid does not fail on clean main/CI. It only fails locally when a developer has a private-image overlay in ~/.spawn/catalog.yaml (the validator wrongly applies the public-only gate to the overlay-merged list). Filed as libs#28. Not related to this PR and does not affect its CI.

#435, #434)

Post-#173 AuthType: AWS_IAM cutover, a DNS Function URL rejects a
bad/absent SigV4 signature with a 403, but the failure was invisible:

- pkg/dns/client.go parsed the 403 body ({"Message":"Forbidden"}) as a
  normal DNSUpdateResponse → empty `DNS API error:`. Now it checks the
  HTTP status and surfaces the code + body snippet.
- pkg/agent: spored records the outcome as spawn:dns-status /
  spawn:dns-error instance tags (best-effort, throttle/deny-tolerant),
  not just an on-instance journal line.
- cmd/status: `spawn status` shows a clear warning when registration
  failed, so the "FQDN never resolves" symptom is diagnosable from the
  launch account.

Tests: 403-not-swallowed (httptest) + dnsStatusNotice table.

Also #434: corrected the stale base36 example in pkg/dns/encoding.go and
the DNS-updater Lambda comment (123456789012 -> 1kpqzg2c, ≤8 chars; code
was already correct).

Note: the root cause of the live 403 (why a freshly-installed, correctly
signing spored is rejected by the AWS_IAM Function URL) is still open —
the Lambda's resource policy and Function URL AuthType are correct
(verified read-only), so it's signature/credential-level; this PR makes
that failure visible rather than silent. See #435 for the ongoing
root-cause investigation.
@codecov

codecov Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.00000% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/agent/agent.go 0.00% 14 Missing ⚠️
pkg/dns/client.go 40.00% 4 Missing and 2 partials ⚠️
cmd/status.go 87.50% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Investigation (see #435) proved every static element correct — resource
policy, dev role's cross-account InvokeFunctionUrl grant, region, and the
SigV4 signing mechanism (a signed probe from BOTH the infra and dev
accounts reaches the Lambda; only UNSIGNED requests get the 403 the
reporter saw). That points to spored signing with empty/anonymous creds
at runtime (IMDS not reachable yet), which SignHTTP does NOT error on —
it produces a signature the AWS_IAM Function URL rejects with a silent
403. Now signRequest fails closed with a clear error when the resolved
credential is empty, rather than emitting an unsigned-effectively request.

Test: TestCallAPI_EmptyCredsFailClosed (no network call, actionable error).
@scttfrdmn
scttfrdmn merged commit 02e9620 into main Jul 23, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/435-dns-registration-visibility branch July 23, 2026 04:24
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.

1 participant