Skip to content

Commit 8e88d8c

Browse files
fix(ci): strip OpenRouter key + read model pins from secrets in baseline refresh
The refresh-baseline run hit a 401 "Missing Authentication header" from OpenRouter. The stored OPENROUTER_API_KEY secret carries a trailing newline; the workflow passed it raw, so it landed in the Authorization header and was rejected (a malformed-header 401, not a bad key). The review action already strips the key, which is why it authenticates — mirror that here. Also: AGENT_MODEL/PARSING_MODEL live in secrets (not vars) in this repo, so the prior `vars.*` reads resolved empty. Read them from secrets and strip whitespace. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6aaebf9 commit 8e88d8c

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

.github/workflows/refresh-baseline.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,28 @@ jobs:
122122
REPO_NAME: ${{ github.event.repository.name }}
123123
DEPTH: ${{ inputs.depth_level }}
124124
MAIN_SHA: ${{ github.sha }}
125-
# OpenRouter key + optional model pins, same secrets the review workflow uses.
126-
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
127-
AGENT_MODEL: ${{ vars.AGENT_MODEL }}
128-
PARSING_MODEL: ${{ vars.PARSING_MODEL }}
125+
# Key + model pins live in SECRETS (not vars) in this repo, same as the
126+
# review workflow consumes them. Read raw here; normalize in the script.
127+
RAW_OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
128+
RAW_AGENT_MODEL: ${{ secrets.AGENT_MODEL }}
129+
RAW_PARSING_MODEL: ${{ secrets.PARSING_MODEL }}
129130
run: |
131+
# Normalize like the review action's key prep: strip surrounding whitespace
132+
# (a trailing newline in the stored secret otherwise lands in the
133+
# Authorization header, which OpenRouter rejects as "Missing Authentication
134+
# header" — a 401 that looks like a bad key but is really a malformed header).
135+
_strip() { printf '%s' "$1" | tr -d '[:space:]'; }
136+
OPENROUTER_API_KEY="$(_strip "$RAW_OPENROUTER_API_KEY")"
130137
[ -n "$OPENROUTER_API_KEY" ] || { echo "::error::OPENROUTER_API_KEY secret is not set."; exit 1; }
131-
# The engine reads the OpenRouter default models when these are empty.
138+
echo "::add-mask::$OPENROUTER_API_KEY"
139+
export OPENROUTER_API_KEY
140+
# Models may carry whitespace too; default to the OpenRouter cheap models
141+
# when unset (the engine also has its own defaults).
142+
AGENT_MODEL="$(_strip "$RAW_AGENT_MODEL")"
143+
PARSING_MODEL="$(_strip "$RAW_PARSING_MODEL")"
132144
export AGENT_MODEL="${AGENT_MODEL:-google/gemini-3-flash-preview}"
133145
export PARSING_MODEL="${PARSING_MODEL:-google/gemini-3.1-flash-lite-preview}"
146+
echo "Provider: openrouter; key length: ${#OPENROUTER_API_KEY}; agent_model: $AGENT_MODEL"
134147
mkdir -p "$OUT_DIR"
135148
# Run the same full-analysis path the review action uses for a base.
136149
uv run python "$ACTION_PATH/scripts/cb_engine.py" base \

0 commit comments

Comments
 (0)