Skip to content

Commit 69bb15e

Browse files
committed
Fail fast on missing env vars in fetch_reviews.sh
Without any guards the script trusted `PR_NUMBER` and the four `NUMBER_OF_*` variables to be set. Missing ones expanded to empty strings, so the script silently constructed paths like `plans//fetched/...` and forwarded empty `-F threads=`, `-F comments=` arguments. `gh` would then reject the call with a generic GraphQL error instead of pointing at the missing variable, while the empty directory had already been created. Add `set -euo pipefail` and a `: "${VAR:?…}"` guard for each of the five required variables, so the script aborts at the missing variable with a clear "VAR is required" message before touching the filesystem or talking to GitHub. `LAST_CURSOR` is intentionally not guarded — it is the optional incremental-fetch cursor and is referenced only through `${LAST_CURSOR:+-F after="$LAST_CURSOR"}`, which is safe under `set -u`. Addresses: - #765 (comment) Assisted-by: Claude Code:claude-opus-4-7
1 parent 090bc8a commit 69bb15e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

.agents/skills/get-reviews/fetch_reviews.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
: "${PR_NUMBER:?PR_NUMBER is required}"
5+
: "${NUMBER_OF_PR_COMMENTS:?NUMBER_OF_PR_COMMENTS is required}"
6+
: "${NUMBER_OF_REVIEWS:?NUMBER_OF_REVIEWS is required}"
7+
: "${NUMBER_OF_THREADS:?NUMBER_OF_THREADS is required}"
8+
: "${NUMBER_OF_COMMENTS_PER_THREAD:?NUMBER_OF_COMMENTS_PER_THREAD is required}"
9+
210
PR_PATH="plans/$PR_NUMBER"
311
FETCHED_PATH="$PR_PATH/fetched"
412
mkdir -p "$FETCHED_PATH"

0 commit comments

Comments
 (0)