Skip to content

fix(cdn): report blocked Fastly domain validation instead of pending - #300

Merged
Meldiron merged 2 commits into
mainfrom
fix/cdn-fastly-blocked-authorizations
Sep 21, 2026
Merged

Meldiron merged 2 commits into
mainfrom
fix/cdn-fastly-blocked-authorizations

Conversation

@Meldiron

@Meldiron Meldiron commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fastly keeps a TLS subscription pending while its authorization is blocked on a _acme-challenge CNAME that only the domain owner can add. FastlyTls::getCertificateStatus() mapped the subscription state alone, so a blocked order looked like progress and a consumer polling for completion waited forever. The Cloud-specific adapter this package replaced used to read the authorizations and report the record; that was lost in the switch, and two customer domains sat in "Generating certificate" for over a week with nothing in their logs but "still waiting".

  • findSubscription() includes tls_authorizations alongside tls_certificates.
  • getCertificateStatus() throws Utopia\Cdn\Exception\Certificate when a referenced authorization for the domain is blocked, or the subscription has failed. The exception carries getStatus() (Status::BLOCKED or Status::FAILED), getChallenges() (typed Certificates\Challenge values: type, recordType, recordName, values) and getWarnings() (Fastly's warnings[].instructions, for example "Conflicting record(s) found at _acme-challenge.example.com…"). The message is self-contained for callers that only log it.
  • Status::BLOCKED is added. It is reported through the exception rather than returned, so a poller cannot mistake it for progress.
  • FastlyTls::CHALLENGE_MANAGED_DNS names the _acme-challenge challenge, the one that proves ownership without pointing the domain itself at Fastly.
  • The managed Fastly provider catches the exception in its reassign path, so a blocked order never moves a live hostname.
  • An issued subscription ignores a stale authorization; authorizations for another domain, or not referenced by the subscription, are ignored; malformed challenges are skipped; warnings alone (authorization still pending) stay pending.

The shape this reads, from GET /tls/subscriptions?filter[tls_domains.id]=www.example.com&include=tls_certificates,tls_authorizations in the reported case:

{
  "data": [{ "id": "…", "attributes": { "state": "pending" },
             "relationships": { "tls_authorizations": { "data": [{ "id": "auth_1", "type": "tls_authorization" }] } } }],
  "included": [{ "id": "auth_1", "type": "tls_authorization",
                 "attributes": {
                   "state": "blocked",
                   "challenges": [{ "type": "managed-dns", "record_type": "CNAME",
                                    "record_name": "_acme-challenge.www.example.com",
                                    "values": ["zl4aax3f2fd367mi8h.fastly-validations.com"] }],
                   "warnings": [{ "type": "dns", "instructions": "Conflicting record(s) found at …" }] } }]
}

Test plan

  • bin/monorepo test cdn: 90 tests, 221 assertions (13 new).
  • bin/monorepo check cdn: Pint, PHPStan level 6 and Rector clean.
  • New cases: blocked authorization on pending/processing/renewing subscriptions; warnings forwarded; a pending authorization is still waited on; failed subscription with and without authorizations; issued ignores a stale authorization; other-domain and unreferenced authorizations ignored; malformed challenges skipped; several challenges offered as alternatives; managed provider leaves a hostname on its service while TLS is blocked.

Related

🤖 Generated with Claude Code

Fastly keeps a TLS subscription `pending` while its authorization is
`blocked` on a `_acme-challenge` CNAME only the domain owner can add, so
mapping the subscription state alone made a blocked order look like
progress and callers polled it forever.

`FastlyTls::getCertificateStatus()` now includes the subscription's TLS
authorizations in the lookup and throws `Exception\Certificate` when one
is blocked or the subscription has failed. The exception carries the
status, the DNS challenges to publish as `Certificates\Challenge` values,
and Fastly's warnings, such as a conflicting record at the challenge
name. The managed Fastly provider keeps a hostname on its current
service while its TLS order is blocked.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@Meldiron Meldiron left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@greptile-apps

greptile-apps Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because the earlier failure-suppression defect is fixed and no new actionable regression was found.

Summary

This PR improves Fastly certificate-state reporting by distinguishing domain-validation blocks from ordinary pending issuance and terminal failures.

  • Includes TLS authorizations when loading subscriptions.
  • Exposes typed DNS challenges, provider warnings, and blocked/failed status through Exception\Certificate.
  • Keeps live hostnames on their existing service while validation is blocked.
  • Preserves terminal failure propagation rather than suppressing it.
  • Adds documentation and coverage for authorization filtering, malformed data, stale authorizations, warnings, and reassignment behavior.

Reviews (2) · Last reviewed commit: "Update packages/cdn/src/Cdn/Certificates..."

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@Meldiron
Meldiron merged commit 2c9dcf6 into main Sep 21, 2026
6 checks passed
Meldiron added a commit that referenced this pull request Sep 21, 2026
Drops the parts of this branch that #300 and #304 already landed on main,
and keeps only what is still unique to it.

Superseded, now taken from main:
- `Exception\Certificate`: main's carries `Challenge` objects, `getWarnings()`
  and `isBlocked()` where this branch had a raw `getDnsRecords()` array.
- `Status::BLOCKED` and the `Provider::getCertificateStatus()` `@throws`.
- `FastlyTls::getCertificateStatus()` blocked-authorization reporting, the
  `tls_authorizations` include, and the ~210 lines of tests covering them.
- The README paragraph describing the old `getDnsRecords()` shape.

Kept from this branch:
- `Fastly`: unlinked and classic-route domain ownership, `fqdn_match=exact`
  with a truncation guard, and `stdClass` response handling.
- `FastlyTls`: the exclusive-ownership check before a `force=true` delete,
  and the `findSubscription()` hardening.

`Fastly::issueCertificate()` now uses main's `catch (Certificate)` around
`getCertificateStatus()` on the reassignment path, since that call throws
on a blocked authorization rather than returning a status.

`bin/monorepo check cdn` passes; 204 CDN tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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