Skip to content

Comments

fix: harden config loading to prevent eval of error output#17

Closed
birme wants to merge 2 commits intomainfrom
fix/harden-config-loading
Closed

fix: harden config loading to prevent eval of error output#17
birme wants to merge 2 commits intomainfrom
fix/harden-config-loading

Conversation

@birme
Copy link
Contributor

@birme birme commented Feb 23, 2026

Summary

Hardens the docker-entrypoint.sh config loading to prevent executing error messages as shell commands.

Problem

When the config-to-env CLI command fails (e.g., expired auth token), its error output was passed directly to eval, producing cryptic errors like Authorization: command not found and loading 0 environment variables. The app would start in a broken state with no config.

Changes

  • Filter output: Only eval lines matching ^export [A-Za-z_][A-Za-z0-9_]*= — ignore any error/debug output
  • Actionable error messages: When config loading fails, log clear guidance ("token may have expired, recreate the app")
  • Show raw output: Include the CLI output in error logs for debugging
  • Distinguish failure modes: Separate handling for CLI exit code failure vs. empty/invalid output

Defense in depth

This is a safety net for the web-runner side. The root cause (missing auth header in config-to-env) is being fixed in EyevinnOSC/client-ts#96.

Ref: Eyevinn/osaas-ai#192 (Issues 1 and 6)

Test plan

  • Test with valid config service → env vars load normally
  • Test with expired/invalid token → clear error message, no eval of error output
  • Test with empty parameter store → warning about 0 vars
  • Verify $? check catches CLI failures correctly

🤖 Generated with Claude Code

birme and others added 2 commits February 22, 2026 19:13
npm's reify step explicitly removes symlinks with the warning
"Removing non-directory /usercontent/node_modules" and creates a
real directory. This means the symlink approach for caching
node_modules on the PVC never worked — packages always installed
to ephemeral storage and were lost on pod restart.

Replace the symlink strategy with copy-based caching:
- After npm install, copy node_modules to /data/node_modules on PVC
- On restart, if lockfile hash matches and cache exists, restore
  node_modules from PVC cache instead of running npm install
- Keep .next/cache symlink as-is (next build follows symlinks correctly)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The entrypoint script was eval'ing the raw output of the config-to-env
CLI command without validation. When the CLI returned error messages
(e.g., "Authorization: Bearer <token>" on auth failures), eval tried
to execute them as shell commands, producing cryptic errors like
"Authorization: command not found" and loading 0 environment variables.

Changes:
- Filter CLI output to only eval valid export statements (grep ^export)
- Log actionable error messages when config loading fails
- Show the raw CLI output for debugging when failures occur
- Distinguish between CLI failure (non-zero exit) and empty/invalid output

Ref: Eyevinn/osaas-ai#192 (Issues 1 and 6)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@birme birme self-assigned this Feb 23, 2026
@birme
Copy link
Contributor Author

birme commented Feb 24, 2026

Closing this PR as redundant — the changes here are covered by more focused PRs:

The eval hardening (filtering to ^export [A-Za-z_][A-Za-z0-9_]*= lines) is a valuable security improvement that PR #20 doesn't include. Filed #23 as a focused follow-up for that.

The node_modules symlink → copy-from-PVC rewrite is a larger behavioral change that should be tracked separately if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant