Troubleshooting Guide
- Devstack
- Port conflicts on start
- Container name already in use
- Stale code in containers
- Garage exits on start
- PostgreSQL exits on start after a change of major version
- A program database is missing in
--shared-dbmode - SOPS decrypt fails
- Battery freezes on desktop-tuned distros
- Firewalled hosts (ufw active) with Docker 28 or newer
- Identity (canopy-identity)
- Tests
- Database
- JDM rulesets (zen-engine 2.1)
- Event bus (RabbitMQ)
- Cross-program orchestration
- Contributor gotchas
- Adding an entry
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 |
|---|---|---|
|
|
CachyOS-family ships 100–150 — battery memory pressure then swaps hot pages. Stock Ubuntu is already 60. |
MGLRU |
|
Default 100 lets the multi-gen LRU evict a working set the battery re-touches within the second. |
|
|
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 |
|
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).
/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.
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.
JDM rulesets (zen-engine 2.1)
| Symptom | Cause | Fix |
|---|---|---|
|
|
Evaluate by the file's name without |
Downstream nodes see |
A decision table or an expression node passes on only the fields it produces. |
Set |
Event bus (RabbitMQ)
| Symptom | Cause | Fix |
|---|---|---|
A subscriber struct fails to deserialise on FTI fields |
The publisher scrubs |
Mark possibly-scrubbed fields |
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. |
|
Cross-program orchestration
| Symptom | Cause | Fix |
|---|---|---|
Program results pend as |
The program service signs with a key the orchestrator cannot verify. |
|
Signature verification fails after a database round-trip |
|
Normalise before signing — microsecond |
Medicaid determinations scored every applicant at a hard-coded age (historic) |
The orchestrator broadcast one generic context; the handler read a top-level |
Fixed by per-program context mappers and per-subject determinations (ADR-035); income and expense amounts are normalised to monthly at the orchestrator seam ( |
Contributor gotchas
-
cargo denyadvisories.validate'sdenystage fails the battery on anycargo deny checkfailure — advisories, bans, licenses, sources — andcargo-denyis a hard preflight requirement (cargo install cargo-deny --locked) (#2239, #1863). The accountable escape for an advisory with no upstream fix is[advisories].ignoreindeny.toml(mostly transitive typst-tree crates, each annotated); remove an entry when the upstream fix lands. -
genis a keyword in edition 2024 — rename the variable. -
std::env::set_varisunsafein edition 2024 and the workspace deniesunsafe_code(Cargo.toml), so env-dependent functions such ascanopy_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.
utoipaembedsToSchemaand#[utoipa::path]doc comments into the spec, so a doc-comment edit changesdocs/modules/ROOT/openapi/.json; runcargo xtask api-docs --updatein the same MR. The gate compares against the *running devstack, so it can pass locally until the stack is rebuilt.