pdf: final review fixes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 files changed,
+172
−25
deploy/billing/sponsored-unlimited.json+1 −0docs/site/pdfs.md+2 −2docs/superpowers/notes/census-proposal-design-pdf-service.md+1 −1docs/superpowers/specs/2026-11-02-pdf-service-design.md+1 −1infra/modules/pdf-host/README.md+4 −0infra/modules/pdf-host/pdf-init.sh.tftpl+8 −3infra/modules/pdf-host/tests/pdf_host.tftest.hcl+96 −1infra/modules/pdf-host/variables.tf+1 −1internal/console/apisystem.go+1 −1internal/console/apisystem_test.go+10 −0internal/console/pdfrenders_test.go+18 −0internal/console/plansponsor_test.go+1 −1internal/console/store.go+1 −0internal/plans/testdata/example-public-pricebook.json+4 −2internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-design-pdf-service.tsv+9 −9system.go+11 −2system_test.go+2 −0
CI passed — run details
diff --git a/deploy/billing/sponsored-unlimited.json b/deploy/billing/sponsored-unlimited.json| index ead502d73..be445a80c 100644 |
| --- a/deploy/billing/sponsored-unlimited.json |
| +++ b/deploy/billing/sponsored-unlimited.json |
| @@ -9,6 +9,7 @@ |
| "storage_self_serve": true, |
| "email_per_day": 2305843009213693951, |
| "bandwidth_bytes_month": 2305843009213693951, |
| + "pdf_renders_month": 2305843009213693951, |
| "custom_domains": true, |
| "fleets": true, |
| "min_schedule_seconds": 1, |
diff --git a/docs/site/pdfs.md b/docs/site/pdfs.md| index 4171b86f1..6519fbe8d 100644 |
| --- a/docs/site/pdfs.md |
| +++ b/docs/site/pdfs.md |
| @@ -72,8 +72,7 @@ Authorization: Bearer <service token> |
| Keep the client's Gotenberg routes and form fields. For example, appending |
| `/forms/chromium/convert/html` to that base reaches the invoice endpoint. |
| -Your app can read its console origin from `CARLOS_CONSOLE` or use the origin |
| -you configured. |
| +Your app can use the console origin you configured. |
| `Gotenberg-Output-Filename` and `Gotenberg-Trace` request headers pass |
| through. Webhook headers are refused. Other `Gotenberg-*` request headers |
| @@ -146,6 +145,7 @@ monthly limit, in that order. |
| | `429` | `this account already has %d PDFs rendering. wait for one to finish and try again` | |
| | `429` | `this account has asked for more than %d PDFs in a minute. try again in a moment` | |
| | `502` | `the PDF engine did not answer. try again shortly` | |
| +| `502` | `could not check this account's plan. Try again` | |
| | `503` | `no PDF engine is configured for this deployment (CARLOS_PDF_ADDR)` | |
| | `503` | `the PDF engine is busy. try again in a few seconds` | |
| | `504` | `the PDF engine took more than 60 seconds and was stopped. try again` | |
diff --git a/docs/superpowers/notes/census-proposal-design-pdf-service.md b/docs/superpowers/notes/census-proposal-design-pdf-service.md| index c4e484d47..c37922fc3 100644 |
| --- a/docs/superpowers/notes/census-proposal-design-pdf-service.md |
| +++ b/docs/superpowers/notes/census-proposal-design-pdf-service.md |
| @@ -25,6 +25,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - new `infra/modules/pdf-host/variables.tf:external`: reads +file:external; written legacy, accepted-legacy, frozen |
| - new `infra/modules/pdf-host/versions.tf:external`: reads +file:external; written legacy, accepted-legacy, frozen |
| -Seal: `3b6cd29b87d2728254936722ab45fdadcfbb8c1f5b74fdfa19d1921b9dfd1dbe` → `2fc38b898e5a7672dfb6066d42a09b57dd367620bae7b9c2d126d0b1659cd856`. |
| +Seal: `3b6cd29b87d2728254936722ab45fdadcfbb8c1f5b74fdfa19d1921b9dfd1dbe` → `3c1c047d5919adccbab7d99a91056ace9a4d69a49ad9d6713aab6fd560b4ce25`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-design-pdf-service.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/specs/2026-11-02-pdf-service-design.md b/docs/superpowers/specs/2026-11-02-pdf-service-design.md| index 2754510cd..0557f7822 100644 |
| --- a/docs/superpowers/specs/2026-11-02-pdf-service-design.md |
| +++ b/docs/superpowers/specs/2026-11-02-pdf-service-design.md |
| @@ -1,7 +1,7 @@ |
| # PDF service: Gotenberg for every app |
| **Date:** 2026-11-02 |
| -**Status:** draft 2, for Paul's read. Builder check (Astra, 2026-11-02) |
| +**Status:** approved by Paul, 2026-11-02. Builder check (Astra, 2026-11-02) |
| raised one question, settled in §4.2: the fence covers the container, |
| not the host. |
| **Asked for by:** Paul, for Sporran on Carloku. Tito Go moves on to it |
diff --git a/infra/modules/pdf-host/README.md b/infra/modules/pdf-host/README.md| index aea112ff2..20e341ba3 100644 |
| --- a/infra/modules/pdf-host/README.md |
| +++ b/infra/modules/pdf-host/README.md |
| @@ -127,6 +127,10 @@ the results for the deployment. |
| 6. With the private-IP flags, capability drop and memory cap enabled, convert |
| uploaded HTML (its `file://` input under `/tmp`) and a LibreOffice document. |
| Both must succeed; a public image by hostname must still load. |
| +7. Render HTML referencing [http://127.0.0.1:3000/health](http://127.0.0.1:3000/health) |
| + and making a JavaScript `fetch` POST to `/forms/chromium/convert/html` on |
| + that origin. None may be fetched. Check the engine log: no second request |
| + may reach the engine. |
| First boot logs `PDF-HOST READY` or `PDF-HOST FAILED` in cloud-init output and, |
| where available, the serial console. A ready message confirms the health |
diff --git a/infra/modules/pdf-host/pdf-init.sh.tftpl b/infra/modules/pdf-host/pdf-init.sh.tftpl| index a2b168397..8f767a10a 100644 |
| --- a/infra/modules/pdf-host/pdf-init.sh.tftpl |
| +++ b/infra/modules/pdf-host/pdf-init.sh.tftpl |
| @@ -41,10 +41,10 @@ cat > /usr/local/sbin/pdf-fence <<'EOF_FENCE' |
| #!/bin/bash |
| set -euo pipefail |
| umask 077 |
| -tok=$(curl -fsS --connect-timeout 3 --max-time 10 -X PUT http://169.254.169.254/latest/api/token \ |
| +tok=$(curl -fsS --connect-timeout 3 --max-time 10 --retry 4 --retry-connrefused --retry-max-time 45 -X PUT http://169.254.169.254/latest/api/token \ |
| -H 'X-aws-ec2-metadata-token-ttl-seconds: 300') |
| imds() { |
| - curl -fsS --connect-timeout 3 --max-time 10 -H "X-aws-ec2-metadata-token: $tok" \ |
| + curl -fsS --connect-timeout 3 --max-time 10 --retry 4 --retry-connrefused --retry-max-time 45 -H "X-aws-ec2-metadata-token: $tok" \ |
| "http://169.254.169.254/latest/meta-data/$1" |
| } |
| ip=$(imds local-ipv4) |
| @@ -129,11 +129,16 @@ Description=PDF container network fence |
| Before=docker.service |
| Wants=network-online.target |
| After=network-online.target |
| +StartLimitIntervalSec=1800 |
| +StartLimitBurst=3 |
| [Service] |
| Type=oneshot |
| ExecStart=/usr/local/sbin/pdf-fence |
| RemainAfterExit=yes |
| +Restart=on-failure |
| +RestartSec=5 |
| +TimeoutStartSec=300 |
| [Install] |
| WantedBy=multi-user.target |
| @@ -160,7 +165,7 @@ docker run -d --name gotenberg --restart=always --network bridge \ |
| --cap-drop=ALL --security-opt no-new-privileges \ |
| -p "$ip:3000:3000" --dns "$resolver" \ |
| '${gotenberg_image}' gotenberg --api-timeout='${api_timeout}' \ |
| - --chromium-deny-list='^file:(?!//\/tmp/).*' \ |
| + --chromium-deny-list='(?i)^file:(?!//\/tmp/).*|^https?://(localhost([.:/]|$)|127\.|0\.0\.0\.0([:/]|$)|\[::1?\]([:/]|$)|(10\.|172\.(1[6-9]|2[0-9]|3[01])\.|192\.168\.)[^/:]+:3000([/?#]|$))' \ |
| --chromium-deny-private-ips --api-download-from-deny-private-ips --webhook-disable |
| # This probe uses the published private address, not the container loopback. |
| curl --fail --silent --show-error --retry 30 --retry-connrefused --retry-delay 2 \ |
diff --git a/infra/modules/pdf-host/tests/pdf_host.tftest.hcl b/infra/modules/pdf-host/tests/pdf_host.tftest.hcl| index 109dd0625..78d224858 100644 |
| --- a/infra/modules/pdf-host/tests/pdf_host.tftest.hcl |
| +++ b/infra/modules/pdf-host/tests/pdf_host.tftest.hcl |
| @@ -103,7 +103,7 @@ run "container_config" { |
| strcontains(local.init_script, "--network bridge"), |
| strcontains(local.init_script, "-p \"$ip:3000:3000\" --dns \"$resolver\""), |
| strcontains(local.init_script, "gotenberg --api-timeout='55s'"), |
| - strcontains(local.init_script, "--chromium-deny-list='^file:(?!//\\/tmp/).*'"), |
| + strcontains(local.init_script, "--chromium-deny-list='(?i)^file:(?!//\\/tmp/).*|"), |
| strcontains(local.init_script, "--chromium-deny-private-ips"), |
| strcontains(local.init_script, "--api-download-from-deny-private-ips"), |
| strcontains(local.init_script, "--webhook-disable"), |
| @@ -223,3 +223,98 @@ run "memory_limit_cannot_inject_shell" { |
| } |
| expect_failures = [var.memory_max] |
| } |
| + |
| +run "chromium_cannot_call_itself" { |
| + command = plan |
| + assert { |
| + condition = alltrue([ |
| + for url in [ |
| + "http://127.0.0.1:3000/health", "http://127.255.255.254/version", |
| + "http://[::1]:3000/forms/chromium/convert/html", "http://[::]:3000/health", |
| + "http://localhost:3000/health", "http://LOCALHOST./health", "http://0.0.0.0:3000/health", |
| + "http://172.17.0.2:3000/forms/chromium/convert/html", "http://10.0.1.23:3000/health", |
| + ] : can(regex("(?i)${try(regex("--chromium-deny-list='[^']*[|](\\^https?[^']*)'", local.init_script)[0], "a^")}", url)) |
| + ]) |
| + error_message = "Chromium must refuse loopback and the Gotenberg API, including the container bridge address" |
| + } |
| + assert { |
| + condition = alltrue([ |
| + for url in ["https://example.com/image.png", "http://example.com:8080/image.png", "http://example.com:3000/image.png", "http://93.184.215.14:3000/image.png"] : |
| + !can(regex("(?i)${try(regex("--chromium-deny-list='[^']*[|](\\^https?[^']*)'", local.init_script)[0], "a^")}", url)) |
| + ]) |
| + error_message = "ordinary public HTTP and HTTPS assets must remain reachable" |
| + } |
| +} |
| + |
| +run "metadata_retry_is_bounded" { |
| + command = plan |
| + assert { |
| + condition = alltrue([ |
| + length(regexall("curl -fsS --connect-timeout 3 --max-time 10 --retry 4 --retry-connrefused --retry-max-time 45", local.init_script)) == 2, |
| + strcontains(local.init_script, "StartLimitIntervalSec=1800\nStartLimitBurst=3"), |
| + strcontains(local.init_script, "Restart=on-failure\nRestartSec=5\nTimeoutStartSec=300"), |
| + strcontains(local.init_script, "Requires=pdf-fence.service\nAfter=pdf-fence.service"), |
| + strcontains(local.init_script, "ExecStartPre=/usr/local/sbin/pdf-fence"), |
| + ]) |
| + error_message = "metadata requests and fence restarts must be bounded while Docker still requires a loaded fence" |
| + } |
| +} |
| + |
| +run "memory_below_minimum_1m" { |
| + command = plan |
| + variables { |
| + memory_max = "1m" |
| + } |
| + expect_failures = [var.memory_max] |
| +} |
| + |
| +run "memory_below_minimum_5m" { |
| + command = plan |
| + variables { |
| + memory_max = "5m" |
| + } |
| + expect_failures = [var.memory_max] |
| +} |
| + |
| +run "memory_below_minimum_5M" { |
| + command = plan |
| + variables { |
| + memory_max = "5M" |
| + } |
| + expect_failures = [var.memory_max] |
| +} |
| + |
| +run "memory_at_or_above_minimum_6m" { |
| + command = plan |
| + variables { |
| + memory_max = "6m" |
| + } |
| +} |
| + |
| +run "memory_at_or_above_minimum_6M" { |
| + command = plan |
| + variables { |
| + memory_max = "6M" |
| + } |
| +} |
| + |
| +run "memory_at_or_above_minimum_10m" { |
| + command = plan |
| + variables { |
| + memory_max = "10m" |
| + } |
| +} |
| + |
| +run "memory_at_or_above_minimum_1g" { |
| + command = plan |
| + variables { |
| + memory_max = "1g" |
| + } |
| +} |
| + |
| +run "memory_at_or_above_minimum_1G" { |
| + command = plan |
| + variables { |
| + memory_max = "1G" |
| + } |
| +} |
diff --git a/infra/modules/pdf-host/variables.tf b/infra/modules/pdf-host/variables.tf| index 27576f6af..991478266 100644 |
| --- a/infra/modules/pdf-host/variables.tf |
| +++ b/infra/modules/pdf-host/variables.tf |
| @@ -57,7 +57,7 @@ variable "memory_max" { |
| type = string |
| default = "3g" |
| validation { |
| - condition = can(regex("^[1-9][0-9]*[mMgG]$", var.memory_max)) |
| + condition = can(regex("^(([6-9]|[1-9][0-9]+)[mM]|[1-9][0-9]*[gG])$", var.memory_max)) |
| error_message = "memory_max must be a positive whole number of MiB or GiB using m or g." |
| } |
| } |
diff --git a/internal/console/apisystem.go b/internal/console/apisystem.go| index e82976122..c8d45b24b 100644 |
| --- a/internal/console/apisystem.go |
| +++ b/internal/console/apisystem.go |
| @@ -229,7 +229,7 @@ func (s *Server) handleAPISystemPDFGet(w http.ResponseWriter, r *http.Request) { |
| rendered, refused, failed, err := s.store.PDFRenderSummary(r.Context(), time.Now().Add(-24*time.Hour)) |
| if err != nil { |
| log.Printf("console: system pdf summary: %v", err) |
| - jsonError(w, http.StatusInternalServerError, err.Error()) |
| + jsonError(w, http.StatusInternalServerError, "internal error") |
| return |
| } |
| out := map[string]any{ |
diff --git a/internal/console/apisystem_test.go b/internal/console/apisystem_test.go| index c1b439273..0afad16a1 100644 |
| --- a/internal/console/apisystem_test.go |
| +++ b/internal/console/apisystem_test.go |
| @@ -231,6 +231,16 @@ func TestSystemPDFStatus(t *testing.T) { |
| t.Fatalf("engine requests: health=%d version=%d", health.Load(), version.Load()) |
| } |
| }) |
| + t.Run("database error is generic", func(t *testing.T) { |
| + fx, token := systemArmed(t, "code-pdf-db-error") |
| + if _, err := fx.st.db.Exec(`DROP TABLE pdf_renders`); err != nil { |
| + t.Fatal(err) |
| + } |
| + status, out := getJSON(t, fx.ts.URL+path, token) |
| + if status != http.StatusInternalServerError || !reflect.DeepEqual(out, map[string]any{"error": "internal error"}) { |
| + t.Fatalf("database error = %d %v, want 500 with generic error", status, out) |
| + } |
| + }) |
| t.Run("unconfigured", func(t *testing.T) { |
| fx, token := systemArmed(t, "code-pdf-unconfigured") |
| status, out := getJSON(t, fx.ts.URL+path, token) |
diff --git a/internal/console/pdfrenders_test.go b/internal/console/pdfrenders_test.go| index 8325faa60..3e0744a84 100644 |
| --- a/internal/console/pdfrenders_test.go |
| +++ b/internal/console/pdfrenders_test.go |
| @@ -1,6 +1,7 @@ |
| package console |
| import ( |
| + "strings" |
| "testing" |
| "time" |
| ) |
| @@ -167,3 +168,20 @@ func TestPDFRenderRecordRequiresPermit(t *testing.T) { |
| t.Fatalf("record wrote without a permit: %d rows", n) |
| } |
| } |
| + |
| +func TestPDFRenderCountUsesCoveringIndex(t *testing.T) { |
| + s := openTestStore(t) |
| + // Migrations also run against stores whose table already exists. |
| + if err := s.migrate(); err != nil { |
| + t.Fatal(err) |
| + } |
| + var id, parent, unused int |
| + var detail string |
| + err := s.db.QueryRow(`EXPLAIN QUERY PLAN SELECT COUNT(*) FROM pdf_renders WHERE account = ? AND outcome = 'rendered' AND at >= ?`, "acct1", 0).Scan(&id, &parent, &unused, &detail) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !strings.Contains(detail, "USING COVERING INDEX") || !strings.Contains(detail, "(account=? AND outcome=? AND at>?)") { |
| + t.Fatalf("monthly count must seek rendered rows by account and time using a covering index: %s", detail) |
| + } |
| +} |
diff --git a/internal/console/plansponsor_test.go b/internal/console/plansponsor_test.go| index 64c9d97e8..16b241621 100644 |
| --- a/internal/console/plansponsor_test.go |
| +++ b/internal/console/plansponsor_test.go |
| @@ -379,7 +379,7 @@ func TestBillingShowsTheSponsorshipAsUnlimited(t *testing.T) { |
| for _, inc := range planIncludes(l, 0) { |
| got = append(got, inc.Text) |
| } |
| - want := []string{"Unlimited apps and instances", "Unlimited disk per app", "Custom domains"} |
| + want := []string{"Unlimited apps and instances", "Unlimited disk per app", "Unlimited PDFs a month", "Custom domains"} |
| if strings.Join(got, "|") != strings.Join(want, "|") { |
| t.Fatalf("includes = %q, want %q", got, want) |
| } |
diff --git a/internal/console/store.go b/internal/console/store.go| index 1b5256982..da5f00190 100644 |
| --- a/internal/console/store.go |
| +++ b/internal/console/store.go |
| @@ -337,6 +337,7 @@ func (s *Store) migrate() error { |
| at INTEGER NOT NULL |
| );`, |
| `CREATE INDEX IF NOT EXISTS pdf_renders_by_account ON pdf_renders (account, at);`, |
| + `CREATE INDEX IF NOT EXISTS pdf_renders_by_account_outcome ON pdf_renders (account, outcome, at);`, |
| `CREATE INDEX IF NOT EXISTS pdf_renders_by_age ON pdf_renders (at);`, |
| // Where an app wants to be told about its email (mailpush.go): one |
| // path per app, POSTed on the app's own platform host. Absent row = |
diff --git a/internal/plans/testdata/example-public-pricebook.json b/internal/plans/testdata/example-public-pricebook.json| index 9df91a15a..874978db4 100644 |
| --- a/internal/plans/testdata/example-public-pricebook.json |
| +++ b/internal/plans/testdata/example-public-pricebook.json |
| @@ -152,7 +152,8 @@ |
| "awake_hours_month", |
| "storage_bytes", |
| "email_per_day", |
| - "bandwidth_bytes_month" |
| + "bandwidth_bytes_month", |
| + "pdf_renders_month" |
| ] |
| } |
| }, |
| @@ -198,7 +199,8 @@ |
| "awake_hours_month", |
| "storage_bytes", |
| "email_per_day", |
| - "bandwidth_bytes_month" |
| + "bandwidth_bytes_month", |
| + "pdf_renders_month" |
| ] |
| } |
| } |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index adc4abd00..755849c26 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -62,4 +62,4 @@ plan14-root-reads-domain-registration-1.tsv 8e7126042fef8cc99899a29e9e06c22763a2 |
| plan14-root-reads-edge-held-streams.tsv c61b055182bf84e822fab92199432bd2d462c268c03ead17c3cfa18f09bd82cd |
| plan14-root-reads-edge-protect-hard-block.tsv 3b6cd29b87d2728254936722ab45fdadcfbb8c1f5b74fdfa19d1921b9dfd1dbe |
| plan14-root-reads-edge-held-first-ping.tsv 3b6cd29b87d2728254936722ab45fdadcfbb8c1f5b74fdfa19d1921b9dfd1dbe |
| -plan14-root-reads-design-pdf-service.tsv 2fc38b898e5a7672dfb6066d42a09b57dd367620bae7b9c2d126d0b1659cd856 |
| +plan14-root-reads-design-pdf-service.tsv 3c1c047d5919adccbab7d99a91056ace9a4d69a49ad9d6713aab6fd560b4ce25 |
diff --git a/internal/provision/testdata/plan14-root-reads-design-pdf-service.tsv b/internal/provision/testdata/plan14-root-reads-design-pdf-service.tsv| index 48bb4d671..cb437c332 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-design-pdf-service.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-design-pdf-service.tsv |
| @@ -3,21 +3,21 @@ |
| # 6 new dispositions: 0 reads re-frozen at their disposition with the claim, 6 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| @legacy bbe2f84ca2d68582fcbcb8f8e251fb8799429cc6989d404e6b12af376f050f7c infra/modules/pdf-host/main.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module source defining the PDF engine box, security group and SSM-only role; never read by the CARLOS root binary or a box agent at runtime file:external@0 40594121a61d33e4c8c2058a101a6f01709c9b052d01e5ab62a0f7fc80f05b41 |
| @legacy 077149cc35ce88d23aedd7c9f8c98a34808e9cc118635ed08969ba0cf0f4f906 infra/modules/pdf-host/outputs.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module outputs for the PDF engine address, instance ID and security group ID; never read by the CARLOS root binary or a box agent at runtime file:external@0 45b004fd2b4134bbbae47a603083227be478ef3c9797c97a04a3417c0277d481 |
| -@legacy 0160d4cbc5f8768ef03cb0252342b68b8bbe1826da2762ead655feb2e8b777b7 infra/modules/pdf-host/pdf-init.sh.tftpl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=cloud-init template run on the PDF engine box at first boot to install the engine and container network fence; never read by the CARLOS root binary or a box agent at runtime file:external@0 4b69151861b721c4264a751cbee92af76f04c39e5ca26af52efe8dacd231b77c |
| -@legacy 489cc00848f3214dbef9ce1c1bf766e4839ba5718b45ba74e09191f61f22a091 infra/modules/pdf-host/tests/pdf_host.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module mock-provider tests for the PDF engine box, IAM, network fence and configuration; never read by the CARLOS root binary or a box agent at runtime file:external@0 0483ec641c3e0070d2296ab42d5ee01890e2112e71e4ef52cea5b1aaecf7ffc4 |
| -@legacy 327867070942e7b36ea5a5ad3d6cbe9574d85de0773b1f04cdce1ca6835a2c8c infra/modules/pdf-host/variables.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module inputs, defaults and validation for the PDF engine box; never read by the CARLOS root binary or a box agent at runtime file:external@0 e03c4b0333f5117fdbb4185a380542c4899115dc6c95cb9d48e934fde645f83a |
| +@legacy 23460e3005efdab31283f8a178a02e88c1dd831c120a15e736e30aee0423caea infra/modules/pdf-host/pdf-init.sh.tftpl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=cloud-init template for the PDF box; add Chromium loopback and private engine-port denial, bounded metadata curl retries and bounded fence-unit restarts; Docker still requires and reloads the fence before starting; never read by the CARLOS root binary or a box agent at runtime file:external@0 a921c067173f7bd95bd222d37f25167cdd6f4f63ff69ef3635f9cad96ff06046 |
| +@legacy 0941bf3ff4dcd1ba3ff4f0282f5b0ca858379b11f2c108998c5f9ba566046e69 infra/modules/pdf-host/tests/pdf_host.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=mock-provider tests add loopback/private engine-port denial and public-asset acceptance, bounded metadata/fence retries and the Docker memory minimum; no live infrastructure calls; never read by the CARLOS root binary or a box agent at runtime file:external@0 a2dbcca1cb692588d7151836c5026e51be8ccdbb970a5c7d370fe9acdf89f7cf |
| +@legacy c402b50151d1faeb4d78a87e0292b88115953c79286cc75587e0bf529fa5967d infra/modules/pdf-host/variables.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module inputs now reject memory_max below 6 MiB while retaining whole MiB/GiB validation; never read by the CARLOS root binary or a box agent at runtime file:external@0 3919e0b520d36160608d4b2135e4494a686100e9f696b2896b3da4abd7310895 |
| @legacy 828be666aef3fef1ab02f78e02137313f9d4b9e2f08c6d8c4bc136f19cdd0f9f infra/modules/pdf-host/versions.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module tool and AWS provider version requirements; never read by the CARLOS root binary or a box agent at runtime file:external@0 bb3be812da255c0f031b2bfdfee462e4687de3681c742b529b55693a8875136b |
| system.go runSystem authority B,C,D,F,G,J4 rev3=census-ruling-self-serve-moves-1;identity=explicit operator CLI uid 0;basis=adds the lifetimes family to the system dispatch (carlos system lifetimes cutover, a console door call as the operator); every existing command branch unchanged;rev3=census-ruling-claims-cleanup-r2;basis=claims cleanup R2: drops the claims case (host.RunSystemClaims, deleted); every other branch unchanged; no read added;rev3=census-ruling-nearest-region-a;basis=adds the hosts-used family to the system dispatch (carlos system hosts-used status, one GET of a console door as the operator); every existing command branch unchanged; no read added;rev3=census-ruling-region-ha-p1a;basis=explicit operator CLI and root units, uid 0: drops the "join" case (host.RunSystemJoin, deleted with internal/host/joinroot.go, its only caller) and its line in the usage text; every other branch unchanged; no read added;rev3=census-ruling-named-unit-delivery-114;basis=the system verb dispatch gains named-units, routed to host.RunSystemNamedUnits; no read of its own;rev3=census-ruling-design-pdf-service;basis=add dispatch for carlos system pdf; no new reads 7f4861660abef9844dbeec756a68d7bb91a655d935b74acd807a85c61453e0f3 |
| system.go systemVerb authority B,C,D,F,G,J4 rev3=census-ruling-self-serve-moves-1;identity=explicit operator CLI uid 0;basis=adds the lifetimes family to the system dispatch (carlos system lifetimes cutover, a console door call as the operator); every existing command branch unchanged;rev3=census-ruling-claims-cleanup-r2;basis=claims cleanup R2: drops "claims" from the verb list, so it now falls to the unknown-verb message; no read added;rev3=census-ruling-nearest-region-a;basis=adds "hosts-used" to the verb list, routed to runSystemHostsUsedVerb; no read added;rev3=census-ruling-region-ha-p1a;basis=explicit operator CLI and root units, uid 0: drops "join" from the verb list, so `carlos system join` now falls to the unknown-verb message; no read added;rev3=census-ruling-named-unit-delivery-114;basis=the known-verb list gains named-units; no read of its own;rev3=census-ruling-design-pdf-service;basis=add recognition for carlos system pdf; no new reads 6fa13065f4396cfac2f2c56b41aab51354cd0d9007b9d875542eef63a7fdb802 |
| infra/modules/pdf-host/main.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module source defining the PDF engine box, security group and SSM-only role; never read by the CARLOS root binary or a box agent at runtime file:external@0 40594121a61d33e4c8c2058a101a6f01709c9b052d01e5ab62a0f7fc80f05b41 |
| infra/modules/pdf-host/outputs.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module outputs for the PDF engine address, instance ID and security group ID; never read by the CARLOS root binary or a box agent at runtime file:external@0 45b004fd2b4134bbbae47a603083227be478ef3c9797c97a04a3417c0277d481 |
| -infra/modules/pdf-host/pdf-init.sh.tftpl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=cloud-init template run on the PDF engine box at first boot to install the engine and container network fence; never read by the CARLOS root binary or a box agent at runtime file:external@0 4b69151861b721c4264a751cbee92af76f04c39e5ca26af52efe8dacd231b77c |
| -infra/modules/pdf-host/tests/pdf_host.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module mock-provider tests for the PDF engine box, IAM, network fence and configuration; never read by the CARLOS root binary or a box agent at runtime file:external@0 0483ec641c3e0070d2296ab42d5ee01890e2112e71e4ef52cea5b1aaecf7ffc4 |
| -infra/modules/pdf-host/variables.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module inputs, defaults and validation for the PDF engine box; never read by the CARLOS root binary or a box agent at runtime file:external@0 e03c4b0333f5117fdbb4185a380542c4899115dc6c95cb9d48e934fde645f83a |
| +infra/modules/pdf-host/pdf-init.sh.tftpl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=cloud-init template for the PDF box; add Chromium loopback and private engine-port denial, bounded metadata curl retries and bounded fence-unit restarts; Docker still requires and reloads the fence before starting; never read by the CARLOS root binary or a box agent at runtime file:external@0 a921c067173f7bd95bd222d37f25167cdd6f4f63ff69ef3635f9cad96ff06046 |
| +infra/modules/pdf-host/tests/pdf_host.tftest.hcl external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=mock-provider tests add loopback/private engine-port denial and public-asset acceptance, bounded metadata/fence retries and the Docker memory minimum; no live infrastructure calls; never read by the CARLOS root binary or a box agent at runtime file:external@0 a2dbcca1cb692588d7151836c5026e51be8ccdbb970a5c7d370fe9acdf89f7cf |
| +infra/modules/pdf-host/variables.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module inputs now reject memory_max below 6 MiB while retaining whole MiB/GiB validation; never read by the CARLOS root binary or a box agent at runtime file:external@0 3919e0b520d36160608d4b2135e4494a686100e9f696b2896b3da4abd7310895 |
| infra/modules/pdf-host/versions.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-design-pdf-service;basis=OpenTofu module tool and AWS provider version requirements; never read by the CARLOS root binary or a box agent at runtime file:external@0 bb3be812da255c0f031b2bfdfee462e4687de3681c742b529b55693a8875136b |
| -@coverage . 04e3067e48f3be37f5c996b2ec2032994b3e69a26d86efee4882dfc4d3580b23 |
| -@coverage infra/modules/pdf-host 11230a33e9ca210a8ae58c3ce009dfc3ed5450a0ab326f93c359007173a590d4 |
| -@coverage infra/modules/pdf-host/tests 00d4614af1937063bcb0a79ab1c67a9182781d604be6db1622ba78d1075ab958 |
| +@coverage . aa87796b4b66f4ce9d20e6d571ef5f348258913fd71833fc75a88f109e41cf77 |
| +@coverage infra/modules/pdf-host cf1322a254574bf20c8fc3da84f4b7979c6b0f07f6bd3925a7af0ab62512c30d |
| +@coverage infra/modules/pdf-host/tests 774a2938ff456990381b40e5317b2bc4faa2bfde95591edbe23b1d17bbcda8e7 |
| @coverage internal/plans 626020904e3d1e996006b968cb8dba8dfcf80b3022160b7d02060040d830f3ea |
| @coverage internal/release a8ada352dd633d1b211e81e4c44fba85d295a44c38f1995696022628083875dc |
| @coverage internal/svcrole e910500ba710dd884ca2f4cf9100a8e1a9573952555554514b97375796937beb |
diff --git a/system.go b/system.go| index 2fdeb848a..8c497c437 100644 |
| --- a/system.go |
| +++ b/system.go |
| @@ -13,6 +13,7 @@ import ( |
| "os" |
| "strings" |
| "time" |
| + "unicode" |
| "github.com/carlosframework/platform/internal/dbreads" |
| "github.com/carlosframework/platform/internal/host" |
| @@ -661,14 +662,22 @@ func runSystemPDFVerb(rest []string) { |
| } |
| func printSystemPDF(w io.Writer, st systemPDFStatus) { |
| + clean := func(s string) string { |
| + return strings.Map(func(r rune) rune { |
| + if unicode.IsControl(r) { |
| + return -1 |
| + } |
| + return r |
| + }, s) |
| + } |
| if !st.Configured { |
| fmt.Fprintln(w, "engine: not configured") |
| } else { |
| fmt.Fprintf(w, "engine: configured at %s\n", st.Addr) |
| if st.Healthy { |
| - fmt.Fprintf(w, "health: ok (Gotenberg %s)\n", st.Version) |
| + fmt.Fprintf(w, "health: ok (Gotenberg %s)\n", clean(st.Version)) |
| } else { |
| - fmt.Fprintf(w, "health: not answering (%s)\n", st.Error) |
| + fmt.Fprintf(w, "health: not answering (%s)\n", clean(st.Error)) |
| } |
| } |
| fmt.Fprintf(w, "last 24 hours: %d rendered, %d refused, %d failed\n", st.Rendered24h, st.Refused24h, st.Failed24h) |
diff --git a/system_test.go b/system_test.go| index 02c3592de..0ccda14b9 100644 |
| --- a/system_test.go |
| +++ b/system_test.go |
| @@ -355,6 +355,8 @@ func TestPrintSystemPDF(t *testing.T) { |
| {"unconfigured", systemPDFStatus{}, "engine: not configured\nlast 24 hours: 0 rendered, 0 refused, 0 failed\n"}, |
| {"healthy", systemPDFStatus{Configured: true, Addr: "http://pdf:3000", Healthy: true, Version: "8.21.1", Rendered24h: 12, Refused24h: 3, Failed24h: 4}, "engine: configured at http://pdf:3000\nhealth: ok (Gotenberg 8.21.1)\nlast 24 hours: 12 rendered, 3 refused, 4 failed\n"}, |
| {"unhealthy", systemPDFStatus{Configured: true, Addr: "http://pdf:3000", Error: "connection refused", Rendered24h: 7}, "engine: configured at http://pdf:3000\nhealth: not answering (connection refused)\nlast 24 hours: 7 rendered, 0 refused, 0 failed\n"}, |
| + {"version controls", systemPDFStatus{Configured: true, Addr: "http://pdf:3000", Healthy: true, Version: "8.\x0021.\x1b1\r\n\t\x7f\u0085"}, "engine: configured at http://pdf:3000\nhealth: ok (Gotenberg 8.21.1)\nlast 24 hours: 0 rendered, 0 refused, 0 failed\n"}, |
| + {"error controls", systemPDFStatus{Configured: true, Addr: "http://pdf:3000", Error: "conn\x1bection\r\n refused\t\x7f\u009b — réessayer"}, "engine: configured at http://pdf:3000\nhealth: not answering (connection refused — réessayer)\nlast 24 hours: 0 rendered, 0 refused, 0 failed\n"}, |
| } { |
| t.Run(tc.name, func(t *testing.T) { |
| var out bytes.Buffer |