Troubleshooting Guide

For a developer whose devstack, test lane, push or build just failed. Each entry is symptom → cause → fix, naming the code that behaves that way. Setup and the cargo xtask dev lifecycle are Local Development; lanes and the push battery are Testing.

Devstack

Port conflicts on start

Symptom: cargo xtask dev start fails with "port already in use".

Cause: host ports are reserved per run and written to .ports.env (xtask/src/docker.rs); a container from a previous project name, or a foreign process, still holds one.

Fix: cargo xtask dev reload (data kept) re-reserves ports. If a container outside this compose project holds the port, find it with docker ps -a and docker rm -f <id>.

Container name already in use

Symptom: The container name /canopy-canopy-tanf-1 is already in use.

Cause: orphan containers from a prior compose project; the project name is the checkout directory name (docker::project_name).

Fix: dev refresh, dev restart and dev clean pass --remove-orphans (xtask/src/devstack_guard.rs, xtask/src/cmd/dev.rs): run cargo xtask dev refresh, or cargo xtask dev restart if the data can go.

Stale code in containers

Symptom: devstack behaviour does not match the code you just changed.

Fix: cargo xtask dev status shows the staleness report; cargo xtask dev refresh does the minimum rebuild; cargo xtask dev reload forces the bounce when refresh says "up to date" and you know better.

Garage exits on start

Cause: Garage v2 requires both rpc_bind_addr and rpc_secret in devstack/garage/garage.toml. Both are set there; a local edit that drops one reproduces the crash.

PostgreSQL exits on start after a change of major version

Symptom: after pulling a change that moves devstack/postgres to another PostgreSQL major, cargo xtask dev start or reload stops at postgres or a program instance, exited 1. Its log says the image stores data under a directory named for the major version, and names PostgreSQL data in /var/lib/postgresql/<the old major>/docker.

Cause: the data volume holds the previous major’s cluster. The image refuses to start beside it rather than open an empty database; it does not upgrade one.

Fix: the devstack’s data is seeded, so wipe it: cargo xtask dev restart, with the profile and --shared-db the stack runs with.

A program database is missing in --shared-db mode

Cause: the shared instance creates its databases from devstack/postgres/init.sql and init-program-dbs.sql only when the volume is first initialised.

Fix: cargo xtask dev restart --shared-db (wipes and re-initialises the volume).

SOPS decrypt fails

Symptom: dev start, reload, restart or refresh aborts with parse sops JSON output or sops --decrypt secrets/dev.yaml exited 0 with no output TWICE.

Cause: sops runs inside the canopy-devtools container with ~/.config/sops/age/keys.txt mounted (xtask/src/cmd/secrets.rs, xtask/src/devtools.rs); the key there is not a recipient of secrets/dev.yaml. When the file is missing altogether, dev start only warns and skips injection.

Fix: reproduce with cargo xtask secrets decrypt; have an existing recipient run cargo xtask secrets add-recipient <age1…> for your public key (.sops.yaml). No host sops or age is involved.

Battery freezes on desktop-tuned distros

Battery workloads (image rebuilds, thousands of DB tests, checkpoint bursts) conflict with aggressive desktop-responsiveness defaults; the symptom is a wall-clock freeze mid-battery. Check these only if your distro tunes for desktop — a stock Ubuntu box has none of these pathologies.

Knob Settled value Why / applicability

vm.swappiness

60

CachyOS-family ships 100–150 — battery memory pressure then swaps hot pages. Stock Ubuntu is already 60.

MGLRU min_ttl_ms

1000

Default 100 lets the multi-gen LRU evict a working set the battery re-touches within the second.

vm.dirty_bytes / vm.dirty_background_bytes

2147483648 / 536870912

On big-RAM boxes the default ratio yields a ~256 MB global ceiling that conscripts every writer into D-state during checkpoint bursts; ~2 GB / 512 MB decouples them.

ananicy-cpp rules for node / headless_shell

nice 0, sched other, ioclass none

CachyOS-family only: the default BG_CPUIO demotion SCHED_IDLEs the whole Playwright tree mid-e2e.

Persistence (bash- and fish-neutral files): /etc/sysctl.d/99-canopy-workstation.conf (the three vm.* lines), /etc/tmpfiles.d/mglru-min-ttl.conf (w! /sys/kernel/mm/lru_gen/min_ttl_ms - - - - 1000), and /etc/ananicy.d/99-local.rules (one JSON rule per binary name).

CAUTION
the sysctl.d line is not sufficient for swappiness on CachyOS-family boxes — /usr/lib/udev/rules.d/30-zram.rules re-asserts vm.swappiness=150 when zram0 initialises, which fires after systemd-sysctl on every boot. Override by copying the rule to /etc/udev/rules.d/30-zram.rules (same filename wins) with the SYSCTL clause set to 60, and re-verify sysctl vm.swappiness after any cachyos-settings package update.

Firewalled hosts (ufw active) with Docker 28 or newer

Container-to-host-published-port hairpin traffic lands on the INPUT chain (pre-28 NAT bypassed the firewall, so long-lived boxes never noticed). Allow the docker address pool: sudo ufw allow from 172.16.0.0/12.

Identity (canopy-identity)

A held bearer answers 401 token_rejected after dev start, reload or restart

Symptom: a token minted earlier (canopy token <SERVICE>, a curl, a test that holds one) is refused with 401 token_rejected under WWW-Authenticate: Bearer error="invalid_token"; the service logs canopy-identity bearer refused with code=token_rejected and the rule the token’s iss is not the issuer.

Cause: the issuer identifier is canopy-web’s public origin plus /identity (https://web.canopy.test:<W>/identity), and dev start, reload and restart sample new ports, so the ingress’s port, and with it the issuer, moves. Every receiver requires iss exactly (crates/canopy-auth/src/identity_token.rs). The services' own calls recover by themselves: a sender re-mints once after a receiver refuses its bearer (canopy_auth::send_with_retry, refuses_the_bearer).

Fix: mint the token again; cargo xtask dev status prints the new origin (Local Development › canopy-web’s origin and the ingress).

canopy-cli answers "no session for this issuer; log in"

Symptom: every canopy-cli command, canopy token <SERVICE> included, fails with no session for this issuer; log in (DeviceError::LoginRequired).

Cause: the profile’s device store holds no session, or one opened under another issuer: a stored session names its issuer, and the device client serves only the profile’s (usable, crates/canopy-auth/src/identity_device_client/client.rs). The devstack profile derives its issuer from .ports.env on every run, so a port move strands the session opened before it; a session that ended (revoked, expired, or refused at refresh) answers the same.

Fix: canopy login (with the same --profile), then approve the code it prints at canopy-web’s /device (canopy-cli).

A browser on the host cannot reach canopy-web, or warns about its certificate

Symptom: the browser cannot resolve web.canopy.test (or idm.canopy.test after the sign-in notice’s Continue), or warns that its certificate is not trusted; no http://localhost:<port>; address serves the worker portal.

Cause: canopy-web publishes no port. Its one host entrance is the TLS ingress at https://web.canopy.test:<W>;, and sign-in continues to Kanidm at https://idm.canopy.test:<P>;; both names are the devstack’s own, and their certificates are signed by the devstack’s CA (xtask/src/devstack_tls.rs).

Fix: add 127.0.0.1 web.canopy.test web.canopy-xsite.test idm.canopy.test to the hosts file and trust .devstack/idp/kanidm-ca.pem; cargo xtask dev status prints both and the origin (Local Development › canopy-web’s origin and the ingress). The tests need neither: they pin the names themselves.

A service refuses to boot: "failed to build the canopy-identity sender (its client key)"

Cause: each service that calls another reads its canopy-identity client key, CANOPY_<SVC>__IDENTITY_CLIENT_PRIVATE_KEY, at boot, with no file fallback (crates/canopy-api/src/bootstrap.rs). On the devstack the key comes from .devstack/identity/env/<client>.env, which xtask writes before the stack’s up; a container started before that file exists (a raw docker compose up after dev clean, say) boots without it.

Fix: bring the stack up through xtask, cargo xtask dev refresh or dev start, which writes the files first (Local Development › Upstream IdP: Kanidm).

Tests

Infrastructure tests panic instead of skipping

Symptom: a lane panics with infrastructure is not available … skipping is forbidden here.

Cause: every cargo xtask lane arms CANOPY_TEST_INFRA=required (xtask/src/bootstrap.rs), and infrastructure_available() panics when Postgres or the rules canary is unreachable (crates/canopy-test-lib/src/infrastructure.rs). A bare cargo nextest run without the variable prints a skip warning instead — the silent skip the battery forbids.

Fix: bring the stack up (cargo xtask dev start, or drop --no-refresh so ensure_ready runs); for one crate use the per-crate lane recipe in Local Development.

nextest recompiles after clippy

Cause: the dev and test profiles are separate compilation targets.

Fix: validate runs cargo clippy --all-targets --features <BATTERY_FEATURES> --profile test — -D warnings so the artifacts are shared (xtask/src/cmd/validate.rs); match that when running clippy by hand. The --features set is BATTERY_FEATURES (xtask/src/lanes.rs, #3343), the battery’s one set: without its portal entries canopy-portal’s test build stops at a compile_error!, and any other set recompiles what the lanes built.

An e2e run reseeded and mutated the devstack

Symptom: after cargo xtask e2e (or a cargo xtask validate that runs it) your hand-made data is gone; the databases hold a fresh 50-household seed plus the e2e run’s mutations.

Cause: cargo xtask e2e always reseeds through cmd::seed::run (xtask/src/cmd/e2e.rs) against the same long-lived devstack. git push no longer runs it.

Fix: do manual setup after the run, or snapshot around it — cargo xtask migrate snapshot before, cargo xtask migrate rollback [--id <snapshot>] after (xtask/src/cmd/migrate.rs). A second checkout under a different directory name gets its own compose project (docker::project_name is the directory name) at roughly double the resources; xtask does not read COMPOSE_PROJECT_NAME.

An e2e page.request.post to canopy-web returns 403

Cause: csrf::csrf_middleware is a route_layer in front of the handlers (services/canopy-web/src/main.rs); a raw POST without the token exercises CSRF, not your handler.

Fix: read input[name="_csrf"] from an in-scope page and send it as the X-CSRF-Token header (services/canopy-web/src/csrf.rs); pattern: tests/e2e/specs/intake-partial-demo.spec.ts.

Reproducing an upstream outage in a Playwright test

Cause: the failing call is server-to-server, so browser route-interception cannot trigger it.

Fix: the devstack /test/fault control surface (Testing › Devstack fault injection); or stop the container (docker stop <project>-canopy-<svc>-1), run the spec with cargo xtask e2e --no-refresh — specs/<name>.spec.ts, then cargo xtask dev reload.

First in-network integration run is slow

Cause: cargo xtask test --integration compiles the test binaries inside the canopy-integration container (ADR-015); later runs reuse the canopy_integration_target volume.

Fix: do not prune that volume; --host runs the same lane on the host.

Database

Service panics with "migrations failed"

Cause: a SQL error, or a migration modified after it was applied.

Fix: migrations are forward-only (ADR-016) — write a corrective migration; in development cargo xtask dev restart wipes and replays. Production restore: Database Backup & Restore.

pool timed out while waiting for an open connection under --shared-db

Cause: every service’s pool lands on one instance.

Fix: already applied — the shared Postgres runs with max_connections=400 (docker-compose.yml); check nothing raises CANOPY_<SVC>__DB_MAX_CONNECTIONS far above its default.

"DATABASE_URL does not match the service name"

Cause: canopy_db::validate_database_name (ADR-001). In CANOPY_ENV=development it warns; elsewhere it fails boot unless CANOPY_DB__ALLOW_NAME_MISMATCH=true (crates/canopy-db/src/lib.rs).

JDM rulesets (zen-engine 2.1)

Symptom Cause Fix

404 rule set not found from canopy-rules

NamedFilesystemLoader keys rulesets by each file’s top-level name, not by filename (services/canopy-rules/src/engine.rs).

Evaluate by the file's name without .json (snap-eligibility, medicaid-magi). cargo xtask rules check fails a file whose name differs from it; a 404 otherwise means no layer of the booted configuration ships the decision.

Downstream nodes see null for fields the upstream emitted

A decision table or an expression node passes on only the fields it produces.

Set passThrough: true in the content of every such node that should keep its inputs, as the shipped rulesets do.

Event bus (RabbitMQ)

Symptom Cause Fix

A subscriber struct fails to deserialise on FTI fields

The publisher scrubs RESTRICTED_FIELDS from the wire before publishing (crates/canopy-mq/src/publisher.rs, ADR-004).

Mark possibly-scrubbed fields #[serde(default)] Option<T> and treat absent as zero-value.

Field-name drift between publisher and subscriber goes uncaught

Schema-less JSON envelope; no compile-time check.

Cross-service integration tests are the backstop; pick the subscriber-side name first and use it on the wire.

Events publish but subscribers receive nothing after a broker restart

The in-process channel went stale.

ConnectionManager reconnects with exponential backoff, single-flight, each attempt bounded at 10 seconds (crates/canopy-mq/src/connection.rs); if a service stays wedged, cargo xtask dev reload.

Cross-program orchestration

Symptom Cause Fix

Program results pend as signature_quarantined in dev (the envelopes land in quarantined_determinations with reason key_unknown or key_unavailable)

The program service signs with a key the orchestrator cannot verify.

dev refresh and every test-lane bring-up generate .keys/<program>-{private,public}.pem (devstack_guard::ensure_signing_keys); dev start alone does not. The orchestrator seeds VerifyingKeyRegistry::from_secrets from CANOPY_VERIFY_KEY_<PROGRAM> or, in development, the public PEM on disk (crates/canopy-signing/src/verifier.rs) and resolves any other key id through canopy-security’s key history (services/canopy-eligibility/src/key_history.rs); a service that boots before canopy-security registered it re-registers on the next dev refresh. Once the key resolves, a determination operator can re-verify the interactive envelopes already quarantined from /ops/quarantined-determinations (worklist).

Signature verification fails after a database round-trip

TIMESTAMPTZ truncates to microseconds and NUMERIC(10,2) rescales decimals, so re-serialised bytes differ from the signed bytes.

Normalise before signing — microsecond created_at and rescale(2) on amounts — as canopy-snap does (services/canopy-snap/src/determine.rs).

Medicaid determinations scored every applicant at a hard-coded age (historic)

The orchestrator broadcast one generic context; the handler read a top-level age the context never set.

Fixed by per-program context mappers and per-subject determinations (ADR-035); income and expense amounts are normalised to monthly at the orchestrator seam (canopy_reference::money::to_monthly, ADR-034).

Contributor gotchas

  • cargo deny advisories. validate's deny stage fails the battery on any cargo deny check failure — advisories, bans, licenses, sources — and cargo-deny is a hard preflight requirement (cargo install cargo-deny --locked) (#2239, #1863). The accountable escape for an advisory with no upstream fix is [advisories].ignore in deny.toml (mostly transitive typst-tree crates, each annotated); remove an entry when the upstream fix lands.

  • gen is a keyword in edition 2024 — rename the variable.

  • std::env::set_var is unsafe in edition 2024 and the workspace denies unsafe_code (Cargo.toml), so env-dependent functions such as canopy_common::env::is_development() are documented rather than unit-tested by mutating the environment.

  • nextest thread caps are fixed per profile in .config/nextest.toml (canopy-owned); the numbers and the serialised groups are in Testing › nextest profiles.

  • OpenAPI snapshots drift from doc comments. utoipa embeds ToSchema and #[utoipa::path] doc comments into the spec, so a doc-comment edit changes docs/modules/ROOT/openapi/.json; run cargo xtask api-docs --update in the same MR. The gate compares against the *running devstack, so it can pass locally until the stack is rebuilt.

Adding an entry

After more than 30 minutes on something that turns out to be a class of issue, add it here as symptom → cause → fix, naming the file that behaves that way.

Edit this page · default