Skip to content

fix(certificates): requeue certificates still being generated - #14009

Merged
HarshMN2345 merged 12 commits into
mainfrom
cursor/sites-custom-domain-https-d27c
Oct 5, 2026
Merged

HarshMN2345 merged 12 commits into
mainfrom
cursor/sites-custom-domain-https-d27c

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

A custom domain on a delayed certificate provider can stay on "Generating certificate" indefinitely. If the first issuance check runs while the provider is still issuing, nothing comes back to it:

  • Interval::verifyDomain only revisits rules in created, which are still waiting on DNS.
  • Maintenance only revisits certificates that have a renewDate, and a pending subscription has none.

So the rule stays in verifying, and the retry endpoint ignores rules in that status. This PR:

  • Requeues them. The interval gains a timer that requeues rules still generating after five minutes, with skipDomainValidation, since DNS already passed when the rule entered that status. Five minutes because $updatedAt is written when a job finishes; a shorter window could requeue a hostname whose previous attempt is still running.
  • Verifies only when ready. For a delayed provider, the worker marks the rule verified once the provider reports the certificate issued or renewing. It then takes the regular issue path, so the certificate stores the provider's renew date.
  • Settles a rule whose certificate needs no renewal. On an instant provider that job now marks the rule verified instead of leaving it generating, where the new timer would requeue it forever.
  • Keeps provider failures retryable. A failure after the provider holds the order stays on generating for up to five attempts instead of moving to unverified, which nothing retries. The security mail goes out once, on the final attempt. DNS failures stay terminal, as before.

A rule the provider keeps pending without failing stays generating and is requeued each tick, capped at 100 rules per tick, until the provider settles it.

Test Plan

No new automated test. AGENTS.md covers workers and tasks through e2e, and e2e cannot reach this path: the worker there always uses Let's Encrypt, which issues synchronously, so a rule never waits on a delayed provider. The existing CertificatesDomainValidationTest cases are unchanged and still describe the flow.

Locally: php -l and Pint on the three files. PHPStan and unit tests run in CI.

To verify on an environment with a delayed provider:

  1. Add a custom domain to a site so that the first certificate job runs while the provider is still issuing. The rule shows "Generating certificate".
  2. Without pressing retry, the rule moves to verified within one interval tick of the provider reporting the certificate issued, and the certificate has a renew date.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

HarshMN2345 and others added 2 commits September 30, 2026 08:45
Identical apex CAA records made Certainly refuse issuance, and an issued Fastly certificate could be left off the TLS configuration so the edge kept serving the shared default cert. Collapse duplicate CAA when a zone is built, create the missing activation before a custom domain can be verified, and recheck rules that are still generating.

Co-authored-by: Harsh Mahajan <[email protected]>
…rating

The interval follow-up only needs to see whether issuance and TLS activation finished. Running DNS verification again can mark the domain unverified on a transient lookup.

Co-authored-by: Harsh Mahajan <[email protected]>
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → cursor/sites-custom-domain-https-d27c (after).

Metric Before After Change
🚀 Requests/sec 200.82 210.62 ⚪ +4.9%
⏱️ Latency P50 87.6 ms 81.8 ms 🟢 -6.6%
⏱️ Latency P95 198.83 ms 194.34 ms ⚪ -2.3%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 81.8 194.34 13,452 210.62 -4.49
Account 166.21 302 708 11.71 +15.6
TablesDB 78.67 145.2 7,316 117.4 -11.16
Storage 74.86 159.75 3,540 58.34 -22
Functions 122.58 241.89 1,888 31.64 +13.08

Top API waits (after)

API request Max wait (ms)
functions.delete 483.03
functions.create 480.82
account.name.update 480.68
functions.variables.update 404.41
account.prefs.update 386.68

@HarshMN2345
HarshMN2345 marked this pull request as ready for review September 30, 2026 08:58
@ghost

ghost commented Sep 30, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The PR adds interval polling for certificates still generating after five minutes and skips repeated DNS validation on those follow-up jobs. The certificate worker checks delayed-provider readiness and keeps provider-stage failures retryable up to five attempts, notifying the security address when attempts are exhausted.

Latest changes: The newest commits inline the worker readiness helpers, mark already-valid instant certificates verified, simplify comments, and namespace certificate-generation span attributes.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
src/Appwrite/Event/Message/Certificate.php Documents the skipDomainValidation flag for previously validated rules.
src/Appwrite/Platform/Tasks/Interval.php Periodically requeues stale generating rules without repeating DNS validation and records scoped polling metrics.
src/Appwrite/Platform/Workers/Certificates.php Checks delayed issuance readiness and retains bounded retryable provider failures before reporting failure.

Reviewed the commits since 4109ae6 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · Looks good to merge. Summary

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Critical risk] Fixes certificate issuance and TLS activation for custom domains.

The PR does not appear safe to merge while a blocked pending Fastly subscription can leave issuance without an automatic follow-up.

Fix All in Claude CodeFindings

  1. P1 Pending issuance loses follow-up ▶
  2. P2 Conflict does not prove activation ▶
  3. P2 Tests mirror activation requests ▶
  4. P2 Worker tests use prohibited tier ▶
  5. P2 Span keys violate naming guide ▶
Fix with agent prompt
### Issue 1
src/Appwrite/Platform/Workers/Certificates.php:undefined-355
If a newly created Fastly subscription is pending while its ownership challenge record propagates, `getCertificateStatus()` can throw for a blocked authorization. This new check then moves the rule from `verifying` to `unverified`. The interval only revisits generating rules, and renewal maintenance requires a renewal date that the pending subscription does not have, so issuance can remain stuck after the challenge becomes valid.

### Issue 2
packages/cdn/src/Certificates/Provider/FastlyTls.php:604-606
The lookup checks for an activation with this certificate, configuration, and hostname, but every subsequent HTTP 409 is accepted as if that activation now exists. If the conflict is with an activation for another certificate, the provider reports the subscription as ready without attaching the selected certificate. Confirm the requested activation after a conflict instead of accepting every 409.

### Issue 3
packages/cdn/tests/Certificates/Provider/FastlyTlsTest.php:105-110
These assertions pin the test to the exact Fastly URL, call index, and serialized request fields. The apex and multi-SAN cases repeat the pattern. An equivalent request flow could fail these tests, while the canned success response does not establish that Fastly would activate the intended hostname. The repository requires tests of observable behavior rather than assertions that mirror source code or configuration; this requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 4
tests/unit/Workers/CertificatesDomainValidationTest.php:80-94
This new test mocks the provider and inspects writes made by the certificate worker; the activation-failure case below does the same. The repository guide explicitly says not to unit-test workers and assigns worker integration behavior to e2e coverage. Move these regressions to that tier before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 5
src/Appwrite/Platform/Tasks/Interval.php:undefined-169
The new `interval.certificate_generation.scanned` key uses dots to separate the task and metric; the new `processed` and `failed` keys follow the same pattern. The repository guide requires snake_case span keys and reserves dots for child relationships. Rename these keys consistently before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR deduplicates identical CAA answers and adds Fastly TLS activation and certificate-generation follow-up handling. The head and previous-review commits have identical source trees, so there are no new changes to comment on.

  • DNS zones publish one copy of an identical CAA record.
  • Issued Fastly subscriptions check for TLS activations before reporting readiness.
  • An interval task queues follow-up certificate-generation work.

Reviews (2) · Last reviewed commit: "fix(sites): skip a second DNS check whil..."

]);

$scanned = \count($rules);
Span::add('interval.certificate_generation.scanned', $scanned);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Span keys violate naming guide The new interval.certificate_generation.scanned key uses dots to separate the task and metric; the new processed and failed keys follow the same pattern. The repository guide requires snake_case span keys and reserves dots for child relationships. Rename these keys consistently before merging.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Platform/Tasks/Interval.php
Line: 169

Comment:
**Span keys violate naming guide** The new `interval.certificate_generation.scanned` key uses dots to separate the task and metric; the new `processed` and `failed` keys follow the same pattern. The repository guide requires snake_case span keys and reserves dots for child relationships. Rename these keys consistently before merging.

**Context Used:** AGENTS.md ([source](https://github.com/appwrite/appwrite/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Keeping these. They mirror the sibling task in the same file on main, interval.domain_verification.{scanned,processed,failed}: the task is the parent and each count is its child, in snake_case. Bare scanned/processed would be ambiguous next to that sibling.


Generated by Claude Code

@cursor
cursor Bot force-pushed the cursor/sites-custom-domain-https-d27c branch from 0b92e48 to be14de4 Compare September 30, 2026 11:29

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Tier B · 1 blocking finding to address. Summary

HarshMN2345 and others added 2 commits October 1, 2026 16:41
Nine review threads, and one of them was a real hole in the fix itself.

Activation failure was a dead end. A failure set the rule to
RULE_STATUS_CERTIFICATE_GENERATION_FAILED, which is 'unverified' -- but the
worker's own guard accepts only generating or verified, and the new interval
requeues only generating. So the one path this PR exists to recover from left
the rule somewhere nothing would ever pick it up again. It now stays on
generating while the only outstanding work is the provider's, bounded by
MAX_GENERATION_ATTEMPTS, and the security mail fires on the terminal attempt
instead of once per retry.

An issued subscription with no certificate on it yet no longer throws. Fastly
reports issued slightly before the certificate appears, and throwing there
turned a normal intermediate state into a failure. getCertificateStatus()
reports PROCESSING instead, so the caller comes back.

A 409 from /tls/activations is no longer assumed to be our own activation. The
conflict can be another certificate holding the hostname, which would have
reported the domain ready while the edge served someone else's certificate. The
provider re-checks and throws when ours is not the one attached.

PHPStan: the new helpers read everything through explicit is_array/is_string
narrowing, so they add no offset-on-mixed errors and the baselined counts in
packages/cdn are untouched (verified pattern by pattern against the base).
extractRenewDate keeps its own extraction for that reason -- sharing the new
helper would have removed a baselined access and broken the count the other way.

Interval: $updatedAt is only written when a job finishes, so a 60-second
threshold could enqueue a hostname whose previous attempt was still running.
Raised to 5 minutes, which is past any provider's job and still inside what a
waiting customer notices. Span keys are now scanned/processed/failed --
Span::init() already names the span, so the old keys were both dot-separated
against the convention and redundant with it.

The CAA collapse is now a general duplicate collapse. An RRset is a set for
every type, not just CAA, and the justification no longer rests on Fastly
treating two identical CAA records as a conflict -- which I could not
substantiate and have retracted on appwrite-labs/cloud#6228. It keys on
everything that distinguishes a record, so MX and SRV differing only in
priority, weight or port both survive.

Tests: FastlyTlsTest no longer asserts exact URLs or indexes into the call
list; it asks which hostnames were activated and with which certificate.
Added the 409-with-another-certificate case and two Zone cases covering the
generalisation.

Verified locally: packages/dns 79 pass, packages/cdn 100 pass, the worker cases
6 pass, and the new bound was seen red by raising it. Pint clean.

HarshMN2345 commented Oct 1, 2026 •

Copy link
Copy Markdown
Member Author

All nine threads addressed in 631bcac. Seven fixed, two I'm standing down on with reasons. One of the findings was a real hole in the fix itself, so starting there.

The activation failure path was a dead end

RULE_STATUS_CERTIFICATE_GENERATION_FAILED is 'unverified'. The worker's own guard accepts only generating or verified, and the new interval requeues only generating. So a rule that failed activation landed somewhere nothing would ever pick it up again — the single path this PR exists to recover from.

It now stays on generating while the only outstanding work is the provider's, bounded by MAX_GENERATION_ATTEMPTS, and the security mail fires on the terminal attempt rather than once per retry. A flag marks the window after the domain's own checks pass, so a DNS failure is still terminal and immediately visible — only provider-side failures are held open.

Covered by two cases: the first failure leaves the rule retryable with attempts = 1; the fifth reports it failed. I confirmed the bound is really under test by raising it to 99 and watching the second case fail.

Pending issuance losing follow-up

Related, and fixed by the same change plus one more: an issued subscription that carries no certificate yet no longer throws. Fastly reports issued slightly before the certificate appears on it, and throwing turned a normal intermediate state into a failure. getCertificateStatus() returns PROCESSING instead, so the caller comes back rather than being pushed into the failure path.

A 409 no longer counts as our activation

Right, and this one could have served the wrong certificate silently. A conflict can be another certificate already holding the hostname — accepting it would report the domain ready while the edge terminates TLS with someone else's cert. The provider now re-checks after a 409 and throws when ours is not the one attached. New case covers the conflict-with-another-certificate branch.

PHPStan

Fixed without touching the baseline. Every read in the new helpers goes through explicit is_array/is_string narrowing, so they contribute no offsetAccess.nonOffsetAccessible errors and the baselined counts in packages/cdn are unchanged — I verified that pattern by pattern against the PR base ('state' 5→5, 'tls_certificates' 1→1, 'not_after' 1→1, 'tls_domain' 1→1). The redundant $bestId !== '' is gone, replaced by the is_string() you suggested.

Worth noting deliberately: extractRenewDate() keeps its own certificate-id extraction rather than sharing the new references() helper. Sharing it would have removed a baselined access and broken the count in the other direction. Minor duplication, stable baseline — happy to consolidate both plus the baseline in a follow-up if you'd rather.

Interval requeue

Valid. $updatedAt is only written when a job finishes, so 60 seconds could enqueue a hostname whose previous attempt was still running. Raised to 5 minutes — past any provider's job duration and still well inside what a customer waiting on issuance notices. I took the larger-threshold option rather than a provider filter because the rule doesn't carry the provider, and a rule stuck in verifying for five minutes is worth requeuing whoever issued it.

Span keys

Fixed, and the finding was righter than it looked: Span::init("interval.{$taskName}") already names the span, so interval.certificate_generation.scanned was both dot-separated against the convention and redundant with its own span. Now scanned / processed / failed. I left the neighbouring interval.domain_verification.* alone — same issue, but pre-existing and not this PR's.

Tests mirroring the request flow

Fixed. No test indexes into $client->calls or asserts an exact URL any more. Two helpers ask the observable question instead — which hostnames were activated, and with which certificate — so the multi-SAN case now reads assertSame(['example.com', 'www.example.com'], …).

The CAA collapse is now a general duplicate collapse

This one needs a correction rather than a defence. The description claimed Fastly's CA treats two identical CAA records as a conflict and stops issuance. I could not substantiate that and have retracted it. The zone served only issue "<the expected CA>" twice with nothing naming another CA, the authorization state was passing with the CAA item in warnings[], and mapStatus() never reads warnings[] at all.

So the collapse is re-justified on what is actually true: an RRset is a set for every type, and RFC 2181 §5 makes publishing the same record twice invalid rather than merely redundant. It now keys on everything that distinguishes a record, so MX and SRV differing only in priority, weight or port both survive — two new ZoneTest cases cover that, since CAA-only dedupe would have passed while silently dropping a valid MX.

I'd still rather this half were judged on that basis than on the Fastly claim.

Standing down: worker tests in the unit tier

Both of you flagged tests/unit/Workers/CertificatesDomainValidationTest.php against AGENTS.md, and the rule is real. I'm not moving them, for two reasons:

  1. The file predates this PR. It already existed with exactly this shape — a mocked Database and Certificates::action() — and this PR adds cases to it. Migrating it is a change to existing coverage, not a fix to this diff.
  2. E2E can't reach this behaviour. What's under test is "the provider reports issued-but-unattached, so the rule must stay retryable." Reproducing that in e2e needs a real CA issuing a real certificate and then withholding activation. There is no seam for that today, so moving these cases means deleting them.

If the tier matters more than the coverage, say so and I'll delete them rather than fake an e2e that doesn't exercise the path.

Verified locally

packages/dns 79 pass, packages/cdn 100 pass, the worker cases 6 pass, Pint clean. Not verified: PHPStan (no binary available in my environment — this is the one claim above I'm asserting by construction rather than by running it) and anything against a live Fastly account. Nothing here has been reproduced end to end; the tests are canned-response unit tests, and that limitation applies to the original diff too.


Generated by Claude Code

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Tier B · See the inline comments. Summary

@HarshMN2345 HarshMN2345 changed the title fix(sites): stop duplicate CAA and missing Fastly TLS activations from breaking custom-domain HTTPS fix(sites): attach the issued TLS certificate so custom domains stop serving the default one Oct 1, 2026
Packages / cdn failed on both, and my previous commit's claim that the baseline
was untouched was only true of src. phpstan.neon is level max over src AND
tests, which I had not accounted for.

Rector: ArrayFirstLastRector wants array_last($ids), not
$ids[array_key_last($ids)]. PHP is 8.5, so array_last() exists.

PHPStan, 26 errors, all in FastlyTlsTest.php, from two separate causes:

The helpers I added read $call['body']['data'][...] -- a chained access on a
mixed receiver -- and declared list<string> while returning list<mixed>. They are
now one activations() returning list<array{domain: string, certificate: string}>,
narrowing before each descent. TestClient types $calls as
array{url:string,method:string,body:mixed}, so only body needs a guard; guarding
url or method would itself trip the always-true check.

The rest was already broken before my commit. The fixture builders mutated
$body['data'][0]['relationships']['tls_certificates'] and appended to
$body['included'], both chained writes on mixed, and both un-baselined. Giving
subscription() a $certificates parameter and issuedSubscription() an
$alsoCertificates parameter removes the mutation entirely, so the tests build
their fixtures instead of patching them.

Every baselined pattern in the test file now matches the pre-PR count exactly
('data' 6, 'id' 3, 'relationships' 4, offset 0 3, 'tls_domain' 1), which is what
the counts were generated from.

The last error was one I would have shipped: subscription()'s new $certificates
parameter had no @PARAM, and missingType.iterableValue fires from level 6 up with
no baseline entry in this package. I had annotated issuedSubscription()'s new
parameters and missed this one. Swept the diff -- every array parameter in the
four changed files is now docblock-typed.

cdn 100 pass, dns 79 pass, worker 6 pass, Pint clean. PHPStan still cannot run
here, so this round was audited by five independent reviewers instead; the
missing @PARAM is what they found, and they confirmed the offsetAccess counts
reconcile.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · Looks good to merge. Summary

HarshMN2345 and others added 2 commits October 1, 2026 11:56
Review caught an asymmetry I introduced. I made ensureActivated() return false
when the subscription carries no certificate to attach, honoured it in the issued
branch, and discarded it in the renewing branch.

My reasoning for discarding it was wrong: I assumed a renewing subscription
without a new certificate is normal because the old one still serves. But
issuedCertificateId() returns null only when there are NO certificate references
at all, which means there is no old certificate either. Nothing is attached and
nothing can be attached, and the worker's isReady() counts renewing as ready --
so that state would have marked the domain verified while the edge served the
default certificate. The same bug the issued branch was fixed for.

Both branches now return PROCESSING, and the docblock says why both have to.

Two tests, the first seen red against the reverted guard: a renewing subscription
with no certificate reports PROCESSING and activates nothing, and one that does
carry a certificate still reports RENEWING and gets attached -- so the guard
cannot swallow the normal path.

cdn 102 pass, Pint clean.

Copy link
Copy Markdown
Member Author

Tests / E2E / PostgreSQL (dedicated) / Teams failed on 20c22c3d20. I don't believe it is this PR's, and I can't name the assertion — both parts with evidence, because the second one is a CI problem worth fixing on its own.

Why it isn't this PR's

The decisive point is the delta. Teams was green at 631bcac368 (job 110344909840: 51 tests, 1346 assertions) and red at 20c22c3d20. git diff between those two heads is two files: packages/cdn/src/Certificates/Provider/FastlyTls.php and its unit test. There is no execution path from a Fastly TLS subscription client to /v1/teams — the class is only instantiated for a project with a custom domain under a configured Fastly provider, and the Teams suite creates teams, memberships and users, so it is never autoloaded in that container.

Supporting, all checked rather than assumed:

  • Green on main in the three most recent push runs, including 36858018860 (head 514e2acb2b, ~5 minutes before this run). So it is not inherited from the 8f90f5c1c1 merge of main either.
  • Green on every earlier head of this branch — be14de4d24, 0b92e48732, 631bcac368.
  • Sole failure among 47 jobs in run 36858527102. Packages / cdn, Tests / Unit and every other E2E service were green.
  • The new certificateGeneration interval timer this PR adds runs at _APP_INTERVAL_DOMAIN_VERIFICATION (default 120s, not overridden in CI). The stack had under ~52s of uptime when tests ended, so it never fired once in this job.
  • The Run tests step failed in a normal 16s with exit code 1 — an assertion failure, not a timeout or crash. The readable log window shows no 5xx, no worker exception, no fatal, and exactly one lock contention, so no lock storm.
  • Base rate: across all 80 failed CI runs since 2026-09-28 (52 reaching the E2E matrix), exactly one had a failing Teams job — this one. Teams is not a habitual flake in that window.

No fix exists to port. This isn't a known breakage with a landed fix, so there is nothing to bring into this PR, and I'm not widening it on a guess.

Why I can't name the assertion — and the fix for that

At this commit, the e2e_service job's Failure Logs step runs an unbounded docker compose logs --timestamps. That dump is ~9,700 of the job's 10,452 lines. The job-log API serves only the last 5,000 lines, so the PHPUnit block — sitting around line 700 — is roughly 4,750 lines outside the window. tail_lines of 3000, 5500 and 11000 all return the same capped 5,000. No JUnit artifact is uploaded (--log-junit writes inside the container), and the only check-run annotation is Process completed with exit code 1.

So the failure is structurally unreadable through the API, which is worse than the failure itself: any future E2E assertion failure in this job is equally invisible.

That fix already exists — commit af8752766f, "ci: bound the e2e service failure log so the failure stays readable", changes the step to docker compose logs --timestamps --tail=150 and cites the 5,000-line window. It is on a sibling branch, not on this head. Whoever owns CI should land it; once it has, a recurrence here is diagnosable in one look.

What I'm doing

Re-running the job once, which is the one re-run this warrants — if it goes green, that closes it; if it reds again, it is real and needs af8752766f landed first so the assertion is actually visible. I'll report either way rather than leave it.

One lead I'll flag precisely so nobody over-reads it: the final request burst matches testDeleteUserUpdatesTeamMembershipCount (tests/e2e/Services/Teams/TeamsBaseServer.php:297) and its assertEventually(..., 30_000, 500) poll. That is simply the last test to finish — the run ended 70ms after its second poll, consistent with that poll succeeding. It is not evidence of the failing test.


Generated by Claude Code

The activation work in this PR could not run. Fastly's constructor hardcoded
tlsConfigurationId: '' when building FastlyTls, ensureActivated() returns
early on an empty one, and nothing could pass a value in -- this is the only
place FastlyTls is constructed outside tests. So POST /tls/activations was
never sent however correct the code behind it was, and an issued certificate
was never attached to its hostname.

The id is now a constructor parameter. Empty stays the default and still means
domain management owns the hostname -- the subscription stays unpinned and no
activation is created -- so nothing changes until a value is supplied.

Two tests, both seen red first against the hardcode: with a configuration id
an issued subscription gets a POST /tls/activations carrying that id, the
certificate and the hostname; without one the status call makes no activation
request at all.

cdn 104 pass, Pint clean. Rector cannot run here (the local vendor's rector
fatals on --version, before reading any file), so CI is the check for it.

HarshMN2345 commented Oct 1, 2026 •

Copy link
Copy Markdown
Member Author

Flagging a correction against myself, because it changes what this PR is worth.

As written, the activation work could not run. Fastly::__construct() hardcoded tlsConfigurationId: '' when building FastlyTls, and ensureActivated() returns early on an empty id:

Fastly.php           tlsConfigurationId: ''      <- only non-test construction of FastlyTls
FastlyTls.php:464    if ($this->tlsConfigurationId === '') { return true; }

So POST /tls/activations could never be sent in production, no matter how correct the code behind it was. Every test that proved the activation logic went through FastlyTls directly and so passed a configuration id itself — which is exactly why none of them caught this.

4109ae6 makes the id a constructor parameter, with two tests on Fastly rather than FastlyTls: given an id, an issued subscription gets a POST /tls/activations carrying that id, the certificate and the hostname; given none, the status call makes no activation request at all. Both were seen red against the hardcode first.

One trap for whoever wires the id

Proxy::select() sends a domainType of site, network or redirect to the network provider, not the custom-domain list:

if (\in_array($domainType, ['site', 'network', 'redirect'], true)) {
    return [$this->networkProvider];
}

and Proxy/Http/Rules/Site/Create.php:148 sets 'deploymentResourceType' => 'site' on a custom domain attached to a Site, which Workers/Certificates.php:211 passes through as domainType. A Sites custom domain — the case this PR comes from — therefore goes through the network provider. Giving a configuration id only to the custom-domain provider would leave the incident path exactly as broken, so both constructions need one, and since each Fastly service terminates TLS on its own configuration they need different ids.

Two things this still does not settle

  1. Empty remains the default and still means Fastly domain management owns the hostname — the subscription stays unpinned and nothing is activated. Whether the deployment should supply a configuration id, or whether domain management is meant to own this path and activation belongs elsewhere entirely, is a design decision I should not make. The incident state argues both models are in play at once: a real TLS subscription and activated: false with routing_configuration_id: null.
  2. activated / routing_configuration_id are still set by nothing in the add-a-domain path. That gap is untouched here.

I'd rather say this plainly than have it found after merge.


Generated by Claude Code

HarshMN2345 and others added 3 commits October 5, 2026 12:00
…eration

The Fastly TLS activation work and the zone duplicate-record cleanup move
to their own pull requests, so each can be merged on its own. What stays
here does not depend on either: the interval requeues rules still
generating, and the worker keeps a provider-side failure retryable.

The worker unit tests go back to main. AGENTS.md covers workers through
e2e rather than unit tests.
@HarshMN2345 HarshMN2345 changed the title fix(sites): attach the issued TLS certificate so custom domains stop serving the default one fix(certificates): requeue certificates still being generated Oct 5, 2026
- A job that finds a valid certificate on an instant provider now marks
  the rule verified. It used to leave it generating, which the interval
  task now requeues every few minutes.
- A delayed provider whose order is already issued falls through to the
  regular issue path, so the certificate keeps the provider's renew date.
  It used to store the current time, which made maintenance requeue it on
  every cycle.
- Inline the single-use helpers into the generation flow, keep main's
  comments where the behaviour is unchanged, and namespace the new span
  keys under interval.certificate_generation like the sibling task.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MeytoiisEusFMCU44PDYav
@HarshMN2345
HarshMN2345 merged commit f198599 into main Oct 5, 2026
64 checks passed
HarshMN2345 added a commit that referenced this pull request Oct 5, 2026
Split out of #14009 so it can be judged on its own.

When FastlyTls has a TLS configuration id, an issued or renewing
subscription gets a TLS activation for every hostname on it, using the
certificate that expires last. A 409 is re-checked rather than taken as
success, since it can mean another certificate already holds the
hostname. An issued subscription that carries no certificate yet reports
processing.

Fastly takes the id as a constructor parameter and forwards it; it was
hardcoded empty. Empty keeps today's behaviour exactly: the subscription
stays unpinned and nothing is activated.
abnegate added a commit that referenced this pull request Oct 5, 2026
Merges main a2cca78 (#14009, #14106, #14117, #14115, #14119, #14114,
#14101, #14125, #14129, #14127) so cloud#5410 can require a train head
that contains main at or after 0ed7232.

Conflicts: none.

Database 8.0 port: none needed. Main's new code only uses Document
getAttribute/setAttribute and Query::equal/lessThan/orderAsc/limit
(Tasks/Interval.php), all unchanged in database 8.0; no removed
Database::* constants, config collections, or model magic reads.
composer.json and composer.lock are untouched by main, so the train's
database and migration pins stay as they are.

Co-Authored-By: Claude Opus 5.5 <[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.

2 participants