Skip to content

Commit 43cd306

Browse files
committed
chore: address review findings
- Add _detectPrevBackend test for env-source SecretRef returning "unknown". - Extract ExecSecretRef / EnvSecretRef named types so the public signature of _resolveSecretRefWithOverrides reads ExecSecretRef instead of Extract<SecretRef, { source: "exec" }>. - Switch README docker run example to --env-file to keep secrets out of shell history and ps output.
1 parent 7cc7e08 commit 43cd306

4 files changed

Lines changed: 15 additions & 9 deletions

File tree

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,12 @@ docker build -t cycling-coach .
302302
303303
docker run -d --name cycling-coach \
304304
-v cycling-coach-data:/data \
305-
-e ANTHROPIC_API_KEY=sk-ant-... \
306-
-e INTERVALS_API_KEY=... \
307-
-e INTERVALS_ATHLETE_ID=i12345 \
308-
-e TELEGRAM_BOT_TOKEN=123456:ABC-DEF... \
305+
--env-file .env \
309306
cycling-coach
310307
```
311308

309+
Use `--env-file` rather than inline `-e KEY=value` flags — inline values land in shell history and are visible to other users via `ps`. Your `.env` should contain `ANTHROPIC_API_KEY` (or `OPENAI_API_KEY` / `GOOGLE_GENERATIVE_AI_API_KEY`), `INTERVALS_API_KEY`, `INTERVALS_ATHLETE_ID`, and `TELEGRAM_BOT_TOKEN`.
310+
312311
The image runs as a non-root user, mounts `/data` for state, and reads `/data/config.yaml` if present. With the `-e` env vars above, no `config.yaml` is required — the legacy env-var fallback (`ANTHROPIC_API_KEY` etc.) covers the three secret fields.
313312

314313
For finer control (custom model, idle timeout, etc.) drop a `config.yaml` into the volume:

src/secrets/resolve.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { spawn } from "node:child_process";
2-
import { SecretRef, SecretResolutionError } from "./types.js";
2+
import { ExecSecretRef, SecretRef, SecretResolutionError } from "./types.js";
33

44
const DEFAULT_TIMEOUT_MS = 30_000;
55
const DEFAULT_MAX_BYTES = 64 * 1024;
@@ -29,7 +29,7 @@ function resolveEnvRef(name: string): string {
2929
}
3030

3131
export async function _resolveSecretRefWithOverrides(
32-
ref: Extract<SecretRef, { source: "exec" }>,
32+
ref: ExecSecretRef,
3333
overrides: { timeoutMs?: number; maxBytes?: number },
3434
): Promise<string> {
3535
const timeoutMs = overrides.timeoutMs ?? DEFAULT_TIMEOUT_MS;

src/secrets/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export type SecretRef =
2-
| { source: "exec"; command: string; args?: string[] }
3-
| { source: "env"; var: string };
1+
export type ExecSecretRef = { source: "exec"; command: string; args?: string[] };
2+
export type EnvSecretRef = { source: "env"; var: string };
3+
export type SecretRef = ExecSecretRef | EnvSecretRef;
44

55
export type SecretResolutionErrorCode =
66
| "ENOENT"

tests/setup.secret-ref.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ describe("_detectPrevBackend", () => {
107107
}),
108108
).toBe("unknown");
109109
});
110+
111+
it("returns unknown for env-source SecretRef (wizard does not manage env refs)", async () => {
112+
const { _detectPrevBackend } = await import("../src/setup.js");
113+
expect(
114+
_detectPrevBackend({ source: "env", var: "ANTHROPIC_API_KEY" }),
115+
).toBe("unknown");
116+
});
110117
});
111118

112119
describe("_formatOrphanCleanup", () => {

0 commit comments

Comments
 (0)