Repository navigation
fix(cdn): recover Fastly certificates and preserve DNS failure details - #222
HarshMN2345 wants to merge 5 commits into
Conversation
| * @param array{resource:array<string, mixed>,included:array<int, array<string, mixed>>} $subscription | ||
| * @return list<string>|null | ||
| */ | ||
| private function getSubscriptionDomains(array $subscription): ?array |
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]>
|
| $this->assertCount(8, $client->calls); | ||
| $this->assertSame('https://api.fastly.com/service/service_1/details', $client->calls[1]['url']); | ||
| $this->assertSame('https://api.fastly.com/tokens/self', $client->calls[2]['url']); | ||
| $this->assertSame('https://api.fastly.com/current_user', $client->calls[3]['url']); | ||
| $this->assertSame('https://api.fastly.com/service?page=1&per_page=20', $client->calls[4]['url']); | ||
| $this->assertSame('PATCH', $client->calls[5]['method']); | ||
| $this->assertSame('https://api.fastly.com/domain-management/v1/domains/domain_1', $client->calls[5]['url']); | ||
| $this->assertSame(['service_id' => 'service_1'], $client->calls[5]['body']); | ||
| $this->assertSame('POST', $client->calls[7]['method']); | ||
| $this->assertSame('https://api.fastly.com/tls/subscriptions', $client->calls[7]['url']); | ||
| $this->assertSame('example.com', $client->calls[7]['body']['data']['relationships']['tls_domains']['data'][0]['id']); |
There was a problem hiding this comment.
Tests mirror request internals
These assertions hard-code the exact request count, lookup order, numeric call indexes, and endpoint sequence. This violates the repository directive to test observable behavior instead of mirroring source code or configuration: a harmless refactor of the preliminary reads will fail even when domain linking and TLS creation still work correctly. The same pattern appears in the pagination test around lines 116–118 and the deletion test around lines 649–652. Assert the required mutation requests and public outcome without fixing every request to a specific array position. This repository requirement must be satisfied before merging.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cdn/tests/Cdn/Certificates/Provider/FastlyTest.php
Line: 32-42
Comment:
**Tests mirror request internals**
These assertions hard-code the exact request count, lookup order, numeric call indexes, and endpoint sequence. This violates the repository directive to test observable behavior instead of mirroring source code or configuration: a harmless refactor of the preliminary reads will fail even when domain linking and TLS creation still work correctly. The same pattern appears in the pagination test around lines 116–118 and the deletion test around lines 649–652. Assert the required mutation requests and public outcome without fixing every request to a specific array position. This repository requirement must be satisfied before merging.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
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!
Comments Outside DiffThese findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.
|
Fastly can return
service_id: nullfor both classic domains and unlinked versionless domains. The managed provider previously treated both as classic, so an orphan could remain without a service association or TLS subscription indefinitely. It now links a confirmed orphan to the configured service before requesting TLS.Ownership checks preserve classic exact and wildcard routes across services, existing routing configurations, and TLS-first transfers between services. Repair requires unrestricted token and user visibility through
/tokens/self,/current_user, and the complete service inventory. Failed lookups, malformed responses, incomplete results, and insufficient permissions stop mutation.Certificate polling now reads the subscription's referenced TLS authorizations. An explicit failed subscription or blocked authorization throws
Utopia\Cdn\Exception\Certificate, carrying its status, provider instructions, and relevant DNS record types, names, and values. Pending warnings remain pending; an issued subscription stays issued even if an included authorization is stale. Unrelated authorization details are excluded.Deletion removes owned orphan records before their TLS subscription so retries can finish partial cleanup. It preserves domains belonging to other services, routing configurations, and wildcard routes, and refuses to delete shared TLS subscriptions. Missing-domain cleanup also checks classic ownership before removing TLS.
Validation:
bin/monorepo check cdn: Pint, PHPStan, and Rector pass.bin/monorepo validateandgit diff --checkpass.The CDN suite uses scripted HTTP responses; it does not perform live Fastly, DNS, or CA E2E requests.
Companion Appwrite retry handling: appwrite/appwrite#13467. Cloud status handling: https://github.com/appwrite-labs/cloud/pull/5639.