Skip to content

Commit 1be7052

Browse files
committed
Fix prompt variable reference and improve error handling in Code Review step
1 parent 0e82c55 commit 1be7052

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

.github/workflows/code-review.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
run: |
6565
PAYLOAD=$(jq -n \
6666
--arg model "$MODEL_NAME" \
67-
--arg prompt "$prompt" \
67+
--arg prompt "$PROMPT" \
6868
'{
6969
model: $model,
7070
prompt: $prompt,
@@ -76,10 +76,10 @@ jobs:
7676
echo "RAW RESPONSE:\n$RAW_RESPONSE"
7777
7878
# Try to extract the response, fallback to a default message if not found
79-
REVIEW=$(echo "$RAW_RESPONSE" | jq -r '.response')
79+
REVIEW=$(echo "$RAW_RESPONSE" | jq -r '.response // empty')
8080
81-
if [ -z "$REVIEW" ]; then
82-
echo "Model did not return a valid review. Check RAW_RESPONSE for errors."
81+
if [ -z "$REVIEW" ] || [ "$REVIEW" = "null" ]; then
82+
echo "Error: .response field is missing or empty in the API response."
8383
REVIEW="Model did not return a valid review. RAW_RESPONSE: $RAW_RESPONSE"
8484
fi
8585
@@ -88,7 +88,7 @@ jobs:
8888
with:
8989
github-token: ${{ secrets.GITHUB_TOKEN }}
9090
script: |
91-
const review = process.env.REVIEW;
91+
const review = process.env.REVIEW || 'No review generated due to an error.';
9292
await github.rest.issues.createComment({
9393
owner: context.repo.owner,
9494
repo: context.repo.repo,

0 commit comments

Comments
 (0)