github-actions[bot] commented on code in PR #61334:
URL: https://github.com/apache/doris/pull/61334#discussion_r2935435033
##########
.github/workflows/opencode-review.yml:
##########
@@ -108,8 +108,53 @@ jobs:
BASE_SHA: ${{ steps.pr.outputs.base_sha }}
- name: Run automated code review
+ id: review
+ continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PROMPT=$(cat /tmp/review_prompt.txt)
- opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6"
+
+ set +e
+ opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6" 2>&1 |
tee /tmp/opencode-review.log
+ status=${PIPESTATUS[0]}
+ set -e
+
+ failure_reason=$(rg -m1 -i '^Error:|SSE read timed out'
/tmp/opencode-review.log || true)
+ if [ "$status" -ne 0 ] && [ -z "$failure_reason" ]; then
+ failure_reason="OpenCode exited with status $status"
+ fi
+
+ if [ -n "$failure_reason" ]; then
+ {
+ echo "failure_reason<<EOF"
+ printf '%s\n' "$failure_reason"
+ echo "EOF"
+ } >> "$GITHUB_OUTPUT"
+ exit 1
+ fi
+
+ - name: Comment PR on review failure
+ if: ${{ steps.review.outcome == 'failure' }}
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ FAILURE_REASON: ${{ steps.review.outputs.failure_reason }}
+ RUN_URL: ${{ github.server_url }}/${{ github.repository
}}/actions/runs/${{ github.run_id }}
+ run: |
+ gh pr comment "${{ github.event.issue.number }}" --body "$(cat <<EOF
+ OpenCode automated review failed and did not complete.
Review Comment:
**Cosmetic: Heredoc indentation causes extra whitespace in PR comment**
The `cat <<EOF` heredoc preserves leading whitespace. Since the body lines
are indented to match the YAML nesting (with 10 spaces), the resulting PR
comment will have each line prefixed with those spaces, making the comment look
oddly formatted on GitHub.
Consider either:
1. Removing the indentation from the heredoc body lines, or
2. Using `<<-EOF` with tab indentation (though this requires actual tabs,
which may not match the file's style), or
3. Passing the body via an env var or file instead of inline heredoc.
##########
.github/workflows/opencode-review.yml:
##########
@@ -108,8 +108,53 @@ jobs:
BASE_SHA: ${{ steps.pr.outputs.base_sha }}
- name: Run automated code review
+ id: review
+ continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PROMPT=$(cat /tmp/review_prompt.txt)
- opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6"
+
+ set +e
+ opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6" 2>&1 |
tee /tmp/opencode-review.log
+ status=${PIPESTATUS[0]}
+ set -e
+
+ failure_reason=$(rg -m1 -i '^Error:|SSE read timed out'
/tmp/opencode-review.log || true)
+ if [ "$status" -ne 0 ] && [ -z "$failure_reason" ]; then
Review Comment:
**Bug: False-positive failure detection when exit status is 0**
The `rg` match is unconditional — it runs regardless of `$status`. If
`opencode` exits with status 0 (success) but the log output happens to contain
a line matching `^Error:` or `SSE read timed out` (e.g., the reviewed code
itself or a review comment discussing errors), then `failure_reason` will be
non-empty and the step will `exit 1`, falsely treating a successful review as a
failure.
Suggested fix: Only search the log for a failure reason when `status != 0`:
```bash
failure_reason=""
if [ "$status" -ne 0 ]; then
failure_reason=$(rg -m1 -i '^Error:|SSE read timed out'
/tmp/opencode-review.log || true)
if [ -z "$failure_reason" ]; then
failure_reason="OpenCode exited with status $status"
fi
fi
```
This way, a successful run (exit 0) is never overridden by incidental log
content.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]