Troubleshooting
Docker & DevStack
Garage initialization fails
The S3-compatible Garage service needs bucket and key initialization after startup. Since C4-gate
(#1012) that runs as the in-graph garage-init compose one-shot on every docker compose up
path — xtask and manual alike — before the seed (which gates on it completing). If you see errors
about missing buckets or access denied:
-
Ensure Garage is healthy:
cargo xtask dev status -
Check the one-shot’s exit state, which
dev statusdoes not list:docker compose -p "$(cargo xtask dev project)" ps -a garage-init; its output:cargo xtask dev logs garage-init -
Re-run it alone:
docker compose -p "$(cargo xtask dev project)" up -d garage-init(idempotent — a persisted garage volume makes it a fast no-op)
No xtask verb shows a one-shot’s exit state or re-runs a single infrastructure service, so steps 2 and 3 call compose on this checkout’s project.
Keycloak hostname errors
Keycloak 26+ uses "hostname v2" configuration.
The KC_HOSTNAME_PORT variable is silently ignored.
KC_HOSTNAME must be a full URL including the port:
KC_HOSTNAME: http://host.docker.internal:8180 # Correct
KC_HOSTNAME: localhost # Wrong — port will default to 443
Postgres "permission denied" / 42501 after #1310
Since #1310 the devstack splits each service’s DB credential: gates connect as
craig_<svc>_owner, serving containers as craig_<svc>_app (DML-only). Symptoms and
remedies:
-
Services fail auth (
password authentication failed for user "craig_<svc>_…") right after pulling #1310: the roles are provisioned bydevstack/postgres/init.sql, which runs only on a FRESH data directory — runcargo xtask dev reseed. -
permission denied(SQLSTATE 42501) on a table: the table was created by a role other than the service’s owner role (e.g. hand-created as thecraigsuperuser), so the owner’s default privileges never fired. Recreate it through a migration (gate-applied), orGRANT SELECT, INSERT, UPDATE, DELETE ON <table> TO craig_<svc>_app;. -
A 42501 on
CREATE/ALTER/DROPfrom a serving container is the boundary WORKING — serving binaries never issue DDL (ADR-063); schema changes go through the migration gates.
RabbitMQ authentication failures
The RabbitMQ user must be defined in devstack/rabbitmq/definitions.json with a SHA-256 password hash.
Environment variables alone do not configure users.
If you change the password, regenerate the hash and update definitions.json.
Port conflicts
cargo xtask dev never publishes the devstack on the static defaults you see in
docker-compose.yml (${CRAIG_PORT_…:-8001} and friends apply only to a raw
docker compose up, which is CI’s shape). Every cold start reserves one host port per
service from the fixed block 20000–24599: the lowest ports that accept a 127.0.0.1
bind, probed together so the set is unique, then recorded in .ports.env — the single
source every test and tool resolves URLs through (cargo xtask dev status prints it).
The block sits outside every OS’s DEFAULT ephemeral client range, so an outbound socket on
the same machine — a nextest battery, a browser — is not auto-assigned one of the devstack’s
ports (a box whose net.ipv4.ip_local_port_range was widened to overlap the block brings
that competitor back; the retry below still covers it, and
net.ipv4.ip_local_reserved_ports=20000-24599 is the optional per-box hardening). Another
explicit listener can still take one: the probe skips listeners on loopback or the wildcard
address, while one bound to a single non-loopback address (or IPv6-only) slips past the
probe and is caught by the retry, which excludes that port on its next attempt
(#1655). The Toxiproxy
fault pool is the one fixed exception: 24600–24663, published on loopback, just above the
block.
The collision message is not a bug in your environment. The start is dependency-ordered,
so the last services bind their host ports tens of seconds after the probe; if something
grabs one in that window, docker compose up fails with the daemon’s
… driver failed programming external connectivity on endpoint craig-<service>-1 (…): failed to bind host port 0.0.0.0:<port>/tcp: address already in use
(older engines: Bind for 0.0.0.0:<port> failed: port is already allocated). xtask
recognises either wording, prints Port collision detected on attempt N/5, discards the
partially-started containers (their logs show a SIGTERM exit 143 — they were deleted, not
crashed), re-probes and retries. A start only fails after five collisions in a row, or when
compose’s stderr says something else entirely — that message is then printed as-is and is
the real problem.
A half-up stack (some containers Created and never started — the shape a collision left
behind before #1655 taught the retry the current daemon wording) recovers in place:
cargo xtask dev start re-reserves and converges. Meanwhile the reconcile step every xtask
verb runs first tolerates it: .ports.env is rewritten from the RUNNING containers, each
absent service is named in a [ports] WARN: <service>:<port> is not running line, and its
derived URLs carry port 0 so nothing dials a stale port.
The discovery step before it asks the main project for its own rows only — the craigidp project’s
redis/authentik/zitadel/kanidm rows are never probed (#1656) — so a
WARN: Could not discover port for <service>:<port> line always names a MAIN-project row compose could
not answer for — a container that is not running — and is worth reading.
only N of the M host ports … are free on start means something is squatting on the
block itself. ss -ltn '( sport >= :20000 and sport ⇐ :24599 )' (Linux),
lsof -iTCP -sTCP:LISTEN -P (macOS) or Get-NetTCPConnection -State Listen | Where-Object {
$.LocalPort -ge 20000 -and $.LocalPort -le 24599 } (Windows PowerShell) names it; a
previous devstack that was never stopped is the
usual culprit — cargo xtask dev status, then cargo xtask dev stop or
cargo xtask dev clean --confirm.
Testing
Random 30-second reqwest timeouts
Nextest defaults to the logical CPU count for parallelism (e.g., 32 threads on a dev machine), which overwhelms the devstack with concurrent connections.
Fix: already configured — every profile in .config/nextest.toml sets test-threads = 8. The history: 16 (the
physical core count) from 2026-03-09, cut back to 8 on 2026-03-22 for pre-push timeouts. Since #1977 the pre-push
battery removes NEXTEST_TEST_THREADS from nextest’s environment, so an exported value no longer raises the battery’s
count (local-dev § Battery threads and the nextest environment).
Keycloak 401 errors during long test runs
Keycloak access tokens have a 30-minute lifetime. If your test session exceeds this, you’ll see 401 Unauthorized errors.
Fix: Re-run the tests. For very long sessions, consider increasing the token lifetime in the Keycloak admin console (Realm Settings → Tokens).
E2E tests fail with DNS errors in CI
CI runs in Docker-in-Docker (DinD).
Services are reachable via Docker Compose service names, not host.docker.internal or localhost.
Correct CI URLs:
CRAIG_E2E_BASE_URL=http://craig-web:8080 # Not http://localhost:8080
OIDC_ISSUER=http://keycloak:8080/realms/craig # Not http://host.docker.internal:8180
Test results location
All test output is saved to test-results/ at the repo root:
-
test-results/e2e/artifacts/— failure screenshots and traces -
test-results/e2e/junit.xml— structured test results -
test-results/ci/unit.xml— unit test results (CI) -
test-results/ci-integration/integration.xml— integration test results (CI)
Pre-push sdk-test pypi DNS flake
The battery’s sdk-test step (cargo xtask sdk-test; in the car, not the pre-push hook) runs the Python SDK suite in a python:3.13-alpine container that pip install`s the build backend (`hatchling) from pypi.org.
It intermittently fails to resolve pypi.org with [Errno -3] Try again (EAI_AGAIN) — a transient DNS failure inside the container, not a code or test defect:
NameResolutionError(host='pypi.org', port=443): Failed to resolve 'pypi.org' ([Errno -3] Try again)
ERROR: No matching distribution found for hatchling
Fix: If the push fails only at the sdk-test/Python stage with this pypi DNS error and every earlier battery stage passed, just re-push (the whole battery re-runs).
Confirm the branch actually landed afterwards with git ls-remote.
reqwest "dns error" against an IPv4 literal = redirect chain
A reqwest error like ConnectError("dns error", …) whose url is a literal IPv4 address (e.g. http://127.0.0.1:38901/) is almost always a redirect chain landing on an unresolvable hostname — not an actual DNS problem with the literal IP.
reqwest’s Error::url() preserves the original requested URL even when the failure occurs mid-redirect, so the message names 127.0.0.1 while the failed lookup was really something like host.docker.internal (a container-only name that does not resolve from outside containers).
Fix: Before suspecting nsswitch / NSS / IPv4-vs-IPv6, disable redirect following — Client::builder().redirect(reqwest::redirect::Policy::none()).
If the error disappears, you were following a redirect chain to an unreachable host.
(A DNS error against a real hostname such as https://example.com may be a genuine DNS problem; this rule applies when the failing URL is a literal IP and the error is unexpected.)
Development
gen or ref used as identifier
Rust 2024 reserves gen and ref as keywords.
If you see a compilation error about reserved keywords, rename the identifier.
For Askama templates specifically:
{% if let Some(x) = value %} // Correct
{% if let Some(ref x) = value %} // Wrong — `ref` is reserved
curl -sf returns wrong status code
When using curl with -f (fail on HTTP errors) and -w '%{http_code}', the -f flag causes the status code to be concatenated with the error output.
Fix: Use -s without -f, and handle errors with || true:
STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/health || true)
CI Pipeline
Pipeline stages
The CI pipeline has 6 stages: check → build → test → scan → promote → deploy (see .gitlab-ci.yml).
-
check, build, test:
ci-imageandxtaskprepare the job image and the xtask binary;carruns the whole battery on a merge request and on a train;docsbuilds the Antora site and checks its links -
scan: the security gates — SAST, secret detection, dependency scanning,
cargo-deny(the RustSec, licence and source scan; change-gated to manifest/advisory files, and on every schedule),secrets-policy, and the scheduled pentest/perf jobs -
promote:
release-buildbuilds, smoke-tests and pushes the service images (tags, the weekly schedule, by hand on main);release-sbomwrites the SBOM (tags, the schedule);release-notes+releaseon tags -
deploy:
pagespublishes the Antora site from main;stop_reviewretires a merge request’s docs review environment (thedocsjob creates it)
Where the full battery runs
The full test battery (the gates, integration, e2e, the perf and security smokes) runs
in CI’s car job, on every merge request that changes code and on every merge-train car
(Quality Gates § CI: the car). The pre-push hook runs only
the fast subset: fmt, the static gates, clippy and the unit tests. The scheduled
pentest/perf-load/perf-stress/cluster-tests jobs run out-of-band.
GitLab API gotchas
Epic notes POST returns 404
Adding a comment to an epic via POST /groups/<id>/epics/<iid>/notes returns 404 for this group.
This is stable behavior (tied to the gitlab.com epic-vs-work-item migration state), not a transient bug or a permissions problem — issue notes (POST /projects/<id>/issues/<iid>/notes) work normally, and only epic notes 404.
Workaround: Append the comment text to the epic’s description instead — GET /groups/<id>/epics/<iid>, then PUT /groups/<id>/epics/<iid> with {"description": "<old>\n\n---\n\n<new>"}.
Closing the epic still works normally via PUT /groups/<id>/epics/<iid> with {"state_event": "close"}.
glab api -f field=@file sends the literal "@file"
glab api --method PUT … -f "description=@/tmp/file" does not read the file — it sends the literal string @/tmp/file as the field value, silently overwriting the target field with that string.
Fix: For large or multi-line PUT bodies (such as an epic/issue description), use curl with an explicit JSON content type:
curl -sS --request PUT \
--header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
--header "Content-Type: application/json" \
--data @/tmp/body.json \
"https://gitlab.com/api/v4/groups/<id>/epics/<iid>" # body.json = {"description": "..."}
glab api --input file.json returns 415 on this endpoint (it does not set Content-Type: application/json).
Always re-fetch after a description PUT and assert the expected markers are present — a silent wrong-body write is otherwise invisible.