|
123 | 123 | # This ensures the apiKeyHelper is properly configured in the config file |
124 | 124 | # If validation fails, exit before running the agent to prevent using wrong credentials |
125 | 125 | if [ -n "$CLAUDE_CODE_API_KEY_HELPER" ]; then |
126 | | - echo "[entrypoint] Validating Claude Code API key helper configuration..." |
| 126 | + echo "[entrypoint] Claude Code API key helper configured: $CLAUDE_CODE_API_KEY_HELPER" |
127 | 127 |
|
128 | | - # Check if config file exists |
| 128 | + # Check if config file exists - if it does, validate it |
| 129 | + # If it doesn't exist yet, skip validation (it may be created by the user command) |
129 | 130 | CONFIG_FILE="$HOME/.claude/config.json" |
130 | | - if [ ! -f "$CONFIG_FILE" ]; then |
131 | | - echo "[entrypoint][ERROR] Claude Code config file not found at $CONFIG_FILE" |
132 | | - echo "[entrypoint][ERROR] Cannot verify apiKeyHelper configuration" |
133 | | - exit 1 |
134 | | - fi |
| 131 | + if [ -f "$CONFIG_FILE" ]; then |
| 132 | + echo "[entrypoint] Validating existing Claude Code config file..." |
| 133 | + |
| 134 | + # Check if apiKeyHelper is present in config file |
| 135 | + if ! grep -q '"apiKeyHelper"' "$CONFIG_FILE"; then |
| 136 | + echo "[entrypoint][ERROR] apiKeyHelper not found in Claude Code config file" |
| 137 | + echo "[entrypoint][ERROR] Expected: {\"apiKeyHelper\":\"$CLAUDE_CODE_API_KEY_HELPER\"}" |
| 138 | + echo "[entrypoint][ERROR] Actual config:" |
| 139 | + cat "$CONFIG_FILE" >&2 |
| 140 | + exit 1 |
| 141 | + fi |
135 | 142 |
|
136 | | - # Check if apiKeyHelper is present in config file |
137 | | - if ! grep -q '"apiKeyHelper"' "$CONFIG_FILE"; then |
138 | | - echo "[entrypoint][ERROR] apiKeyHelper not found in Claude Code config file" |
139 | | - echo "[entrypoint][ERROR] Expected: {\"apiKeyHelper\":\"$CLAUDE_CODE_API_KEY_HELPER\"}" |
140 | | - echo "[entrypoint][ERROR] Actual config:" |
141 | | - cat "$CONFIG_FILE" >&2 |
142 | | - exit 1 |
143 | | - fi |
| 143 | + # Verify the value matches the environment variable |
| 144 | + CONFIGURED_HELPER=$(grep -o '"apiKeyHelper":"[^"]*"' "$CONFIG_FILE" | cut -d'"' -f4) |
| 145 | + if [ "$CONFIGURED_HELPER" != "$CLAUDE_CODE_API_KEY_HELPER" ]; then |
| 146 | + echo "[entrypoint][ERROR] apiKeyHelper mismatch:" |
| 147 | + echo "[entrypoint][ERROR] Environment variable: $CLAUDE_CODE_API_KEY_HELPER" |
| 148 | + echo "[entrypoint][ERROR] Config file value: $CONFIGURED_HELPER" |
| 149 | + exit 1 |
| 150 | + fi |
144 | 151 |
|
145 | | - # Verify the value matches the environment variable |
146 | | - CONFIGURED_HELPER=$(grep -o '"apiKeyHelper":"[^"]*"' "$CONFIG_FILE" | cut -d'"' -f4) |
147 | | - if [ "$CONFIGURED_HELPER" != "$CLAUDE_CODE_API_KEY_HELPER" ]; then |
148 | | - echo "[entrypoint][ERROR] apiKeyHelper mismatch:" |
149 | | - echo "[entrypoint][ERROR] Environment variable: $CLAUDE_CODE_API_KEY_HELPER" |
150 | | - echo "[entrypoint][ERROR] Config file value: $CONFIGURED_HELPER" |
151 | | - exit 1 |
| 152 | + echo "[entrypoint] ✓ Claude Code API key helper validated: $CLAUDE_CODE_API_KEY_HELPER" |
| 153 | + else |
| 154 | + echo "[entrypoint] Config file not found yet - will be created by user command" |
| 155 | + echo "[entrypoint] Environment variable set: CLAUDE_CODE_API_KEY_HELPER=$CLAUDE_CODE_API_KEY_HELPER" |
152 | 156 | fi |
153 | | - |
154 | | - echo "[entrypoint] ✓ Claude Code API key helper validated: $CLAUDE_CODE_API_KEY_HELPER" |
155 | 157 | fi |
156 | 158 |
|
157 | 159 | # Print proxy environment |
|
0 commit comments