[GH-ISSUE #1020] [Issue]: Claude Subscription provider silently returns empty response when HOME and runtime user diverge (Docker compose) #497

Closed
opened 2026-10-20 17:29:30 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @aeriondyseti on GitHub (May 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1020

Originally assigned to: @cha1latte on GitHub.

Summary

Two related problems in the Claude Subscription provider surface together in Docker: (1) authentication paths break silently when HOME differs from the runtime user's natural home (the compose default), and (2) when the Claude Agent SDK returns a successful stream with zero text_delta events, the provider yields nothing and the route logs a vague "Empty response from model" warning with no upstream diagnostic. The user is left guessing — they see only "The AI returned an empty response. Try sending your message again." in the UI.

Expected behavior

  • A user running docker compose up and logging into Claude via docker exec should be able to use a Claude Subscription connection without manually fixing up file paths or symlinks.
  • When the SDK call completes but produces no usable output, the provider should throw a specific, actionable error that names the most likely cause (auth, fast-mode downgrade, model rejection) — not silently yield nothing.

Actual behavior

(1) Auth path mismatch under compose

  • docker-compose.yml sets HOME=/app on the marinara service.
  • The server process drops privileges to uid 1000 (node) via scripts/docker-entrypoint.mjs, but HOME is preserved from the compose env, not reset to node's /etc/passwd entry (/home/node).
  • When a user docker execs into the container to install/login with the claude CLI, the CLI uses $HOME to find/write config. As node, that's /home/node/.claude/ and /home/node/.claude.json — not /app/.claude/ where the server-side SDK looks.
  • The Claude Agent SDK bundled in the image (@anthropic-ai/claude-agent-sdk@0.2.126) had previously written a stub /app/.claude.json (393 bytes, root-owned, no oauthAccount) when something initialized with HOME=/app as root early in container life.
  • Result: the SDK reads the stub, doesn't see a logged-in account, and quietly degrades to a no-auth/incomplete state. The actual OAuth tokens at /home/node/.claude/.credentials.json are never consulted.

(2) Silent zero-delta stream → "empty response"

Tracing the failure on ghcr.io/pasta-devs/marinara-engine:latest (commit c247b2eb, pre-#991):

  • The SDK query() iterator completes without throwing.
  • Zero content_block_delta { type: "text_delta" } events are produced.
  • claude-subscription.provider.ts yields nothing.
  • generate.routes.ts:6834 sees fullResponse.trim() === "" and writes the user-facing error at generate.routes.ts:6868:

    "The AI returned an empty response. Try sending your message again."

  • The only log between SDK invocation and that warning is the route-layer logger.warn — no provider-level diagnostic, no fast-mode state, no billing/model info, no auth-mode indicator.

PR #991 partially mitigates (it adds verbose debug logs for the resume path and throws loudly on SDK errors), but a successful-but-empty stream still falls through without an error.

Steps to reproduce

(1) Auth mismatch

  1. docker compose up (uses ghcr.io/pasta-devs/marinara-engine:latest).
  2. docker exec -it marinara-engine-marinara-1 bash (lands in /app as root, but the npm-installed claude CLI typically lives under the node user's home).
  3. Install claude CLI and run claude login as the user it's actually installed for. Credentials land at /home/node/.claude/.credentials.json.
  4. In the Marinara UI, create a Claude Subscription connection (e.g. Haiku 4.5), send a single message.
  5. Observe: "The AI returned an empty response. Try sending your message again." Server logs show only [generate] Empty response from model for chat ... at warn level.

(2) Silent zero-delta

Same as above. The auth mismatch is one cause; any other cause that produces a zero-delta stream (silent fast-mode downgrade, tool-only assistant response, model refusal, account-tier gating) would produce the same opaque user message.

Workaround (until fixed)

Inside the running container:

docker exec -u node marinara-engine-marinara-1 sh -c '
  ln -sfn /home/node/.claude      /app/.claude
  ln -sfn /home/node/.claude.json /app/.claude.json
'

These symlinks live in the writable layer and do not persist across docker compose down. The cleaner workaround is to login with the right HOME from the start:

docker exec -u node -e HOME=/app marinara-engine-marinara-1 claude login

Proposed fixes

A few options, listed cheapest → most thorough:

  1. docker-compose.yml: drop HOME=/app (or set HOME=/home/node). DATA_DIR=/app/data is already explicit, so HOME doesn't need to override the user's natural home for the data dir to land in the right place.
  2. scripts/docker-entrypoint.mjs: after dropPrivileges(), set process.env.HOME to the dropped user's pw_dir from /etc/passwd so the SDK and any subprocess inherit the right path.
  3. Documentation: call out in docs/CONFIGURATION.md (Docker section) that subscription users must either (a) login with -e HOME=/app set or (b) accept that the in-container claude login writes to /home/node and won't be visible to the server.
  4. Observability (independent of the auth fix, address even if #1/#2 land): in claude-subscription.provider.ts, detect the "stream completed AND zero text deltas yielded AND zero result.usage tokens" case and throw new Error("Claude (Subscription) returned no content — likely auth, fast-mode downgrade, or model rejection. Check the claude CLI session and the server logs around this timestamp."). The user-facing message can still be friendly, but the server should leave a usable breadcrumb.
  5. Optional, in PR #991 follow-up: log auth resolution at debug level on the first call after boot — which credentials path the SDK resolved, whether the resume path is enabled, what $HOME looks like. Cheap to add, valuable for future bug reports.

Environment

  • Marinara Engine version: 1.6.0 (ghcr.io/pasta-devs/marinara-engine:latest, revision c247b2ebd6f2b6274cb7284e37d6ad382aafa6ac)
  • Install type: docker (compose)
  • Host OS: Ubuntu 25.10, Docker 29.5.0
  • Browser: N/A — backend issue, reproducible from any client

Logs, screenshots, or video

Server logs at the time of failure (compose :latest, fold path, no PR #991):

marinara-1  | [docker-entrypoint] Repairing ownership for /app/data/storage
marinara-1  | {"level":40,"...":"[auth-bypass] BYPASS_AUTH_DOCKER=true — clients in 172.16.0.0/12 will skip Basic Auth and IP allowlist"}
marinara-1  | {"level":40,"...":"[generate] Empty response from model for chat FWV7N7QXEJvYOdAm7THEb (char: __professor_mari__)"}
marinara-1  | {"level":40,"...":"[generate] Empty response from model for chat FWV7N7QXEJvYOdAm7THEb (char: __professor_mari__)"}
marinara-1  | {"level":40,"...":"[generate] Empty response from model for chat FWV7N7QXEJvYOdAm7THEb (char: __professor_mari__)"}

The diagnostic gap: zero provider-level log lines between [auth-bypass] (boot) and [generate] Empty response (route).

Files discovered during diagnosis (inside the container):

Path Expected Actual
/home/node/.claude/.credentials.json OAuth tokens ✅ valid, 471 bytes
/home/node/.claude.json full CLI config ✅ 24,584 bytes
/app/.claude/.credentials.json OAuth tokens (where SDK looks) ❌ missing
/app/.claude.json full CLI config (where SDK looks) ❌ 393-byte stub, no oauthAccount

Additional context

  • Symlinking both /app/.claude and /app/.claude.json to the /home/node originals fully resolved the empty-response symptom — confirms the auth mismatch is the trigger for this specific report.
  • PR #991 (feat/claude-subscription-jsonl-resume) is in flight and partially addresses (4)/(5) above by wrapping the SDK call in a try/catch that re-throws with a friendly prefix. It does not currently catch the "stream completed but yielded nothing" case.
  • The claude CLI's choice to use $HOME (not getpwuid(geteuid())->pw_dir) is standard Unix behavior and not something to "fix" upstream — the responsibility is on the container to make those resolve to the same place.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @aeriondyseti on GitHub (May 19, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1020 Originally assigned to: @cha1latte on GitHub. ## Summary Two related problems in the Claude Subscription provider surface together in Docker: (1) authentication paths break silently when `HOME` differs from the runtime user's natural home (the compose default), and (2) when the Claude Agent SDK returns a successful stream with zero `text_delta` events, the provider yields nothing and the route logs a vague `"Empty response from model"` warning with no upstream diagnostic. The user is left guessing — they see only `"The AI returned an empty response. Try sending your message again."` in the UI. ## Expected behavior - A user running `docker compose up` and logging into Claude via `docker exec` should be able to use a Claude Subscription connection without manually fixing up file paths or symlinks. - When the SDK call completes but produces no usable output, the provider should throw a specific, actionable error that names the most likely cause (auth, fast-mode downgrade, model rejection) — not silently yield nothing. ## Actual behavior ### (1) Auth path mismatch under compose - `docker-compose.yml` sets `HOME=/app` on the marinara service. - The server process drops privileges to uid 1000 (`node`) via `scripts/docker-entrypoint.mjs`, but `HOME` is preserved from the compose env, **not** reset to `node`'s `/etc/passwd` entry (`/home/node`). - When a user `docker exec`s into the container to install/login with the `claude` CLI, the CLI uses `$HOME` to find/write config. As `node`, that's `/home/node/.claude/` and `/home/node/.claude.json` — **not** `/app/.claude/` where the server-side SDK looks. - The Claude Agent SDK bundled in the image (`@anthropic-ai/claude-agent-sdk@0.2.126`) had previously written a stub `/app/.claude.json` (393 bytes, root-owned, no `oauthAccount`) when something initialized with `HOME=/app` as root early in container life. - Result: the SDK reads the stub, doesn't see a logged-in account, and quietly degrades to a no-auth/incomplete state. The actual OAuth tokens at `/home/node/.claude/.credentials.json` are never consulted. ### (2) Silent zero-delta stream → "empty response" Tracing the failure on `ghcr.io/pasta-devs/marinara-engine:latest` (commit `c247b2eb`, pre-#991): - The SDK `query()` iterator completes without throwing. - Zero `content_block_delta { type: "text_delta" }` events are produced. - `claude-subscription.provider.ts` yields nothing. - `generate.routes.ts:6834` sees `fullResponse.trim() === ""` and writes the user-facing error at `generate.routes.ts:6868`: > "The AI returned an empty response. Try sending your message again." - The only log between SDK invocation and that warning is the route-layer `logger.warn` — **no provider-level diagnostic**, no fast-mode state, no billing/model info, no auth-mode indicator. PR #991 partially mitigates (it adds verbose debug logs for the resume path and throws loudly on SDK errors), but a successful-but-empty stream still falls through without an error. ## Steps to reproduce ### (1) Auth mismatch 1. `docker compose up` (uses `ghcr.io/pasta-devs/marinara-engine:latest`). 2. `docker exec -it marinara-engine-marinara-1 bash` (lands in `/app` as root, but the npm-installed `claude` CLI typically lives under the `node` user's home). 3. Install `claude` CLI and run `claude login` as the user it's actually installed for. Credentials land at `/home/node/.claude/.credentials.json`. 4. In the Marinara UI, create a Claude Subscription connection (e.g. Haiku 4.5), send a single message. 5. Observe: "The AI returned an empty response. Try sending your message again." Server logs show only `[generate] Empty response from model for chat ...` at warn level. ### (2) Silent zero-delta Same as above. The auth mismatch is one *cause*; any other cause that produces a zero-delta stream (silent fast-mode downgrade, tool-only assistant response, model refusal, account-tier gating) would produce the same opaque user message. ## Workaround (until fixed) Inside the running container: ```sh docker exec -u node marinara-engine-marinara-1 sh -c ' ln -sfn /home/node/.claude /app/.claude ln -sfn /home/node/.claude.json /app/.claude.json ' ``` These symlinks live in the writable layer and **do not persist across `docker compose down`**. The cleaner workaround is to login with the right HOME from the start: ```sh docker exec -u node -e HOME=/app marinara-engine-marinara-1 claude login ``` ## Proposed fixes A few options, listed cheapest → most thorough: 1. **`docker-compose.yml`:** drop `HOME=/app` (or set `HOME=/home/node`). `DATA_DIR=/app/data` is already explicit, so HOME doesn't need to override the user's natural home for the data dir to land in the right place. 2. **`scripts/docker-entrypoint.mjs`:** after `dropPrivileges()`, set `process.env.HOME` to the dropped user's `pw_dir` from `/etc/passwd` so the SDK and any subprocess inherit the right path. 3. **Documentation:** call out in `docs/CONFIGURATION.md` (Docker section) that subscription users must either (a) login with `-e HOME=/app` set or (b) accept that the in-container `claude login` writes to `/home/node` and won't be visible to the server. 4. **Observability (independent of the auth fix, address even if #1/#2 land):** in `claude-subscription.provider.ts`, detect the "stream completed AND zero text deltas yielded AND zero `result.usage` tokens" case and `throw new Error("Claude (Subscription) returned no content — likely auth, fast-mode downgrade, or model rejection. Check the `claude` CLI session and the server logs around this timestamp.")`. The user-facing message can still be friendly, but the server should leave a usable breadcrumb. 5. **Optional, in PR #991 follow-up:** log auth resolution at debug level on the first call after boot — which credentials path the SDK resolved, whether the resume path is enabled, what `$HOME` looks like. Cheap to add, valuable for future bug reports. ## Environment - Marinara Engine version: 1.6.0 (`ghcr.io/pasta-devs/marinara-engine:latest`, revision `c247b2ebd6f2b6274cb7284e37d6ad382aafa6ac`) - Install type: docker (compose) - Host OS: Ubuntu 25.10, Docker 29.5.0 - Browser: N/A — backend issue, reproducible from any client ## Logs, screenshots, or video Server logs at the time of failure (compose `:latest`, fold path, no PR #991): ``` marinara-1 | [docker-entrypoint] Repairing ownership for /app/data/storage marinara-1 | {"level":40,"...":"[auth-bypass] BYPASS_AUTH_DOCKER=true — clients in 172.16.0.0/12 will skip Basic Auth and IP allowlist"} marinara-1 | {"level":40,"...":"[generate] Empty response from model for chat FWV7N7QXEJvYOdAm7THEb (char: __professor_mari__)"} marinara-1 | {"level":40,"...":"[generate] Empty response from model for chat FWV7N7QXEJvYOdAm7THEb (char: __professor_mari__)"} marinara-1 | {"level":40,"...":"[generate] Empty response from model for chat FWV7N7QXEJvYOdAm7THEb (char: __professor_mari__)"} ``` The diagnostic gap: zero provider-level log lines between `[auth-bypass]` (boot) and `[generate] Empty response` (route). Files discovered during diagnosis (inside the container): | Path | Expected | Actual | |---|---|---| | `/home/node/.claude/.credentials.json` | OAuth tokens | ✅ valid, 471 bytes | | `/home/node/.claude.json` | full CLI config | ✅ 24,584 bytes | | `/app/.claude/.credentials.json` | OAuth tokens (where SDK looks) | ❌ missing | | `/app/.claude.json` | full CLI config (where SDK looks) | ❌ 393-byte stub, no `oauthAccount` | ## Additional context - Symlinking both `/app/.claude` and `/app/.claude.json` to the `/home/node` originals fully resolved the empty-response symptom — confirms the auth mismatch is the trigger for this specific report. - PR #991 (`feat/claude-subscription-jsonl-resume`) is in flight and partially addresses (4)/(5) above by wrapping the SDK call in a try/catch that re-throws with a friendly prefix. It does not currently catch the "stream completed but yielded nothing" case. - The `claude` CLI's choice to use `$HOME` (not `getpwuid(geteuid())->pw_dir`) is standard Unix behavior and not something to "fix" upstream — the responsibility is on the container to make those resolve to the same place. ## Template check - [ ] I DID NOT read this template and provide the requested details. <!-- I (a Claude Code agent) read the template. Unticking this box truthfully reflects that. -->
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#497
No description provided.