Skip to content

Troubleshooting Guide ​

This guide covers common issues encountered during Gatez deployment and operation, with root causes and fixes derived from real production debugging.


Portal Issues ​

"Could not load configuration" on tenant drawer tabs ​

Symptoms: Prompt Config, Usage, Providers, or Guards tabs show "Could not load configuration. Check your connection or try again."

Root cause: The page uses a hardcoded API URL (like VITE_CP_API_URL) that falls back to localhost:4001, which is unreachable in production (ports are not exposed).

Fix: All API calls must use apiFetch() from @gatez/api-client with relative paths. The apiFetch function prepends VITE_API_URL automatically.

typescript
// Wrong
const resp = await fetch(`${CP_API}/api/tenants/${id}/prompt-config`);

// Correct
const resp = await apiFetch(`/api/tenants/${id}/prompt-config`);

Portal shows the password form but no SSO button ​

Symptoms: the operator or developer portal shows only the built-in login; the SSO button is missing.

Root cause: the portal reads /config.json, written at container start from GATEZ_SSO_ENABLED (which follows GATEZ_SSO_FEDERATION) and GATEZ_SSO_CLIENT_ID. With federation off the button is hidden by design and every identity-provider bearer is refused with 401 sso_not_configured. With SSO on but no client id the portal container refuses to start (gatez portal config: GATEZ_SSO_CLIENT_ID is required in its log) rather than hiding the button.

Verify:

bash
curl -s http://localhost:3003/config.json
docker compose logs operator-portal | grep "gatez portal config"   # a refused value names the variable

Fix: set GATEZ_SSO_FEDERATION=true, the sso profile and ZITADEL_OPERATOR_CLIENT_ID / ZITADEL_DEVELOPER_CLIENT_ID (written by scripts/zitadel-setup.sh), then docker compose up -d operator-portal developer-portal — nothing is rebuilt, the config is runtime.

Dark mode resets on page refresh ​

Symptoms: Theme reverts to light mode after refreshing.

Root cause: Theme preference was not persisted to localStorage.

Fix: Already fixed in the codebase. The theme is saved to localStorage.setItem('gatez-theme', theme) and restored on app startup before React renders.

Portal shows "unhealthy" in Docker ​

Symptoms: docker ps shows operator-portal or developer-portal as (unhealthy).

Root cause: The Docker healthcheck uses wget -qO- http://localhost:80/ but the portal serves correctly via Caddy externally.

Impact: Cosmetic only. The portal works fine when accessed via its external URL.

Verify:

bash
curl -s -o /dev/null -w "%{http_code}" https://operator.yourdomain.com
# Should return 200

APISIX Issues ​

APISIX returns 400 when creating a route with a plugin ​

Symptoms: PUT /apisix/admin/routes/{id} returns HTTP 400.

Root cause: The plugin configuration doesn't match the plugin's JSON schema. Every APISIX plugin validates its config on route creation.

Common examples:

  • limit-count requires count and time_window (not just {})
  • ip-restriction requires either whitelist or blacklist
  • traffic-split requires rules with weighted_upstreams

Fix: Provide valid config. See APISIX Plugin Reference for each plugin's required fields.

Custom plugin not loadable on routes ​

Symptoms: Route creation with clickhouse-logger, group-auth, or response-pii-scrub returns 400 even with valid config.

Root cause: The extra_lua_path in apisix.yaml doesn't match the Docker volume mount path for custom plugins.

Verify:

bash
# Check where plugins are mounted
docker inspect apisix --format '{{range .Mounts}}{{.Source}} -> {{.Destination}}{{"\n"}}{{end}}' | grep plugin

# Check extra_lua_path in config
docker exec apisix cat /usr/local/apisix/conf/config.yaml | grep extra_lua_path

Fix: Ensure the volume mount paths match the extra_lua_path pattern in apisix.yaml.

APISIX admin API not reachable in production ​

Symptoms: curl localhost:9180/apisix/admin/routes returns "Connection refused".

Root cause: The production overlay (docker-compose.prod.yml) strips all ports with ports: !reset []. APISIX admin is only accessible within the Docker network.

Fix: Use docker exec to access from inside the network:

bash
docker exec apisix curl -s http://localhost:9180/apisix/admin/routes \
  -H "X-API-KEY: your-admin-key"

Or access via the CP API which queries APISIX internally.


Deploy Issues ​

Container name conflict ("already in use") ​

Symptoms: Deploy fails with "The container name /operator-portal is already in use".

Root cause: A manually-created container (docker run --name operator-portal) conflicts with a compose-managed container of the same name.

Fix:

bash
docker rm -f operator-portal developer-portal
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d

deploy_only guard fails ​

Symptoms: "No successful CI run found for SHA" when using deploy_only=true.

Root cause: The auto-fix agent pushed a commit after the last CI passed, creating a new SHA with no green CI.

Fix: Run a full pipeline (not deploy_only):

bash
gh workflow run ci.yml --ref main
# Not: gh workflow run ci.yml --ref main -f deploy_only=true

GHCR pull returns 403 ​

Symptoms: "403 Forbidden" when pulling images from ghcr.io on the VM.

Root cause: Private repository images require authentication. The GITHUB_TOKEN in CI may not have read:packages scope when used from the VM.

Impact: The deploy script falls back to building locally (docker compose build), which is slower but works.

Fix for faster deploys: Create a GitHub Personal Access Token with read:packages scope and store as a secret.

Since W1-D4-04 every built service carries its registry name in compose (image: + build:), so a host can pull a released tag instead of building:

bash
echo "$GHCR_TOKEN" | docker login ghcr.io -u <github-user> --password-stdin
cd /opt/gatez && git checkout <sha>
export GATEZ_IMAGE_TAG=<sha>
docker compose -f docker-compose.yml -f docker-compose.prod.yml pull --ignore-pull-failures
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d      # anything CI did not publish for <sha> is built from the checkout
docker logout ghcr.io                                                      # do not leave the token in ~/.docker/config.json

Put GATEZ_IMAGE_TAG=<sha> in the host .env so later up calls keep the same images. CI publishes an image only for layers that changed in that commit and (until the ci.yml hunk from W1-D4-04 lands) no portal images, hence the build fallback. Without a login, or on an air-gapped host, the build path is the whole story: docker compose build produces images under the same names (GATEZ_IMAGE_REPO points at an internal registry; docker load preloaded images and start with up --pull never). The default tag local is never published by CI, so a pull of it always fails and compose builds the checkout.

Smoke test fails after deploy ​

Symptoms: Smoke test reports "APISIX admin API not reachable" even though services are running.

Root cause: The smoke test script (scripts/smoke-test.sh) uses localhost:9180 which is not exposed in production. Or --force-recreate restarted APISIX and it needs time to reconnect to etcd.

Fix: Production deploy smoke tests should use external URLs:

bash
curl -s https://api.yourdomain.com/health
curl -s https://operator.yourdomain.com

Data Issues ​

ClickHouse analytics charts show no data ​

Symptoms: Analytics page shows empty charts despite the platform being operational.

Root cause: The clickhouse-logger plugin is not attached to APISIX routes, so no request data flows to ClickHouse.

Verify:

bash
# Check if routes have clickhouse-logger
docker exec apisix curl -s http://localhost:9180/apisix/admin/routes \
  -H "X-API-KEY: your-key" | grep clickhouse-logger

# Check ClickHouse row count
docker exec clickhouse clickhouse-client --query "SELECT count() FROM gateway.request_log_raw"

Fix: The CP API auto-injects clickhouse-logger on new routes. For existing routes, re-create them or seed demo data:

bash
bash scripts/seed-demo-data.sh

Zitadel token rejected by CP API ​

Symptoms: API calls return "Invalid or expired token" even with a valid Zitadel session.

Root cause: The CP API validates JWT signatures via JWKS. If the JWKS cache is stale or the Zitadel organization doesn't have the expected client, validation fails.

Verify:

bash
# Check CP API logs for JWKS refresh
docker logs control-plane-api --tail 20 | grep JWKS

# Is federation on at all? With GATEZ_SSO_FEDERATION=false every IdP token is refused by design.
docker compose exec control-plane-api env | grep -E "GATEZ_SSO_FEDERATION|KEYCLOAK_JWKS_URL"

# Built-in sessions do not depend on the IdP: this must work regardless
TOKEN=$(curl -s -X POST http://localhost:4001/api/auth/login -H 'Content-Type: application/json' \
  -d '{"email":"admin@gatez.local","password":"<your password>"}' | python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])")
curl -H "Authorization: Bearer $TOKEN" http://localhost:4001/api/tenants

Fix: set GATEZ_SSO_FEDERATION=true with the sso profile and verify KEYCLOAK_JWKS_URL points at the IdP's JWKS endpoint. CP API logs should show "JWKS cache refreshed, key_count: 2".


CI/CD Issues ​

TypeScript lint fails in CI ​

Symptoms: CI job "TypeScript Lint" fails with import.meta.env errors.

Root cause: tsconfig.base.json missing "types": ["vite/client"]. Vite augments ImportMeta with env var types.

Fix: Already fixed. Ensure tsconfig.base.json includes:

json
{
  "compilerOptions": {
    "types": ["vite/client"]
  }
}

Security check fails with ".claude/ files committed" ​

Symptoms: CI security check reports ".claude/ files are committed!"

Root cause: Someone used git add -f .claude/ to force-add files that are in .gitignore.

Fix:

bash
git rm --cached .claude/product/roadmap.md  # remove from tracking, keep local
git commit -m "Remove .claude from git tracking"

Pre-push hook fails with uncommitted files ​

Symptoms: git push rejected with "N uncommitted file(s) in source directories".

Root cause: The auto-fix code review agent modified files in the background after your commit.

Fix: Stage and commit the additional changes:

bash
git add <files listed>
git commit -m "fix: auto-fix agent improvements"
git push

Performance Issues ​

Zitadel slow to start (30-60 seconds) ​

Symptoms: Zitadel healthcheck takes 60+ seconds. Tests that depend on Zitadel fail with timeouts.

Root cause: Zitadel startup + organization initialization takes 30-60 seconds, especially on CI runners with limited CPU.

Fix: Use retry logic when checking Zitadel:

bash
# Retry up to 90 seconds
for i in $(seq 1 18); do
  curl -sf http://localhost:8085/debug/healthz && break
  sleep 5
done

Docker Compose stack uses too much memory ​

Symptoms: Services crash or become unresponsive, especially Zitadel and ClickHouse.

Root cause: The full stack (18 containers) requires ~8-10 GB RAM. Docker Desktop default may be 4 GB.

Fix: Increase Docker Desktop memory to 16 GB. Or reduce Zitadel resource limits:

yaml
# docker-compose.yml
deploy:
  resources:
    limits:
      memory: 512M

Routes frozen by an unknown plugin, or rate limiting failing open ​

Symptoms: every write to a route answers 400 unknown plugin [...]; the APISIX error log shows tenant-rate-limit: Redis unavailable, FAILING OPEN ... WRONGPASS; a route stops appearing in gateway.request_log. Cause: the route carries a plugin name no longer in the APISIX plugin list (the built-in clickhouse-logger and http-logger after the 3.18 upgrade) or a redis_password from an old .env. Audit and repair:

bash
set -a; . ./.env; set +a                       # on a host: REDIS_PASSWORD + APISIX_ADMIN_KEY
bash scripts/apisix-route-sanity.sh            # report only, exit 1 when there are findings
bash scripts/apisix-route-sanity.sh --fix      # dead loggers → gatez-clickhouse-logger, passwords → current
bash scripts/apisix-route-sanity.sh --delete-junk   # remove routes matching --junk-pattern (default: April E2E leftovers)
  • --keys (W2-D6-16): also audits consumer scoping — OPENKEY = a key-auth route with no consumer-restriction (every tenant's key is admitted; report only, grant the right consumers from the control plane and lock it), FOREIGN = a whitelist naming a consumer of another tenant than the route's labels.tenant_id, with the consumer's tenant read from its APISIX record (desc "Tenant: x"; live admin API or --consumers-file) — --fix drops those names and an emptied whitelist becomes the !gatez-deny-all sentinel; FOREIGN? = the same from a {tenant}_ username-prefix guess only, reported and never stripped. setup-routes.sh runs the audit with --fix --keys on every deploy.
  • After deploying the W2-D6-16 build on a host with existing keys: POST /api/keys/grants/backfill (platform admin, master key) re-grants every stored active key on its routes; then review the OPENKEY lines and lock each open route once its consumers are granted (PATCH /apisix/admin/routes/<id>/plugins/consumer-restriction with the granted usernames, or the sentinel for none).

scripts/setup-routes.sh runs the audit in fix mode at the end of every deploy.

Agents answer 403 policy_missing after a deploy (W2-D7-01) ​

Since W2-D7-01 the agent gateway denies tool calls for a tenant that has no stored tool policy. Before, a missing policy meant "allow everything". After the first deploy of this change:

  1. List the tenants that run agent sessions.
  2. For each one, check GET /v1/policies/<tenant>; "stored": false means no policy is saved.
  3. Save one with PUT /v1/policies/<tenant> (allowlist, HITL tools, blast-radius limits), or re-run the seed: scripts/seed-demo-data.sh stores the insurance and retail policies, scripts/seed-sandbox.sh stores the demo tenant policy. payflow and wealth get no policy on purpose.
  4. The Operator Portal shows the same under Agents → Policies.

Before deploying W2-D7-38 (guard vocabulary): stored guard configs become live ​

Until W2-D7-38 the AI gateway silently ignored any stored tenant guard config that used the Guards tab's block / log actions, and ignored mode entirely. After the deploy those stored values take effect on the first request: enabled: false, an empty override_patterns or mode: permissive switches a tenant's guards off; mode: strict rejects every PII match and rejects when the webhook is down.

  1. Dump every stored config: redis-cli --scan --pattern '*:guard:config' and GET each key.
  2. Check enabled, mode, override_patterns and webhook_url per tenant with the operator.
  3. Fix or delete the key before the deploy; the Guards tab (W2-D7-38.b) shows the same values.

Enterprise API + AI + Agent Gateway