mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 00:08:55 +00:00
fix: deepseek write error: Broken pipe and Argument list too long (#11940)
This commit is contained in:
@@ -79,18 +79,16 @@ jobs:
|
||||
PR_NUMBER="${{ steps.pr.outputs.pr_number }}"
|
||||
EXISTING_COMMENT_ID="${{ steps.find_comment.outputs.comment_id }}"
|
||||
|
||||
EXISTING_BODY=""
|
||||
if [ -n "$EXISTING_COMMENT_ID" ]; then
|
||||
EXISTING_BODY=$(gh api "repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT_ID" --jq '.body')
|
||||
gh api "repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT_ID" \
|
||||
--jq '.body' > /tmp/existing_body.txt
|
||||
else
|
||||
printf '' > /tmp/existing_body.txt
|
||||
fi
|
||||
|
||||
PR_DIFF=$(cat /tmp/pr_diff.txt)
|
||||
PR_COMMITS=$(cat /tmp/pr_commits.json)
|
||||
DIFF_TRUNCATED=$(echo "$PR_DIFF" | head -n 6000)
|
||||
head -n 6000 /tmp/pr_diff.txt > /tmp/pr_diff_truncated.txt
|
||||
|
||||
SYSTEM_PROMPT="You are a senior code reviewer. Review the following PR diff for bugs, security issues, and performance problems. Skip style suggestions, documentation, and trivial improvements. Be concise — 2 sentences max per issue. Max 10 issues. Prioritize by severity."
|
||||
|
||||
INSTRUCTIONS=$(cat <<'ENDINSTRUCTIONS'
|
||||
cat > /tmp/instructions.txt <<'ENDINSTRUCTIONS'
|
||||
## Code Review Request
|
||||
|
||||
**Repository:** ${{ github.repository }}
|
||||
@@ -111,17 +109,29 @@ jobs:
|
||||
|
||||
### OUTPUT FORMAT — FAILURE TO FOLLOW MEANS YOU FAILED
|
||||
|
||||
You MUST output ONLY the comment exactly as shown. NO preamble, NO "Here is the review", NO markdown outside the table.
|
||||
You MUST output ONLY the comment exactly as shown. NO preamble, NO "Here is the review".
|
||||
|
||||
Issues found:
|
||||
```
|
||||
<!-- deepseek-pr-review -->
|
||||
## Code Review
|
||||
|
||||
| # | File | Severity | Issue |
|
||||
|---|------|----------|-------|
|
||||
| 1 | `path/file:line` | 🔴 High | Description. **Fix:** suggestion |
|
||||
<details>
|
||||
<summary>🔴 High: `path/file:line`</summary>
|
||||
|
||||
Description of the issue. **Fix:** suggestion.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>🟡 Medium: `path/file:line`</summary>
|
||||
|
||||
Description of the issue. **Fix:** suggestion.
|
||||
|
||||
</details>
|
||||
```
|
||||
|
||||
Each issue MUST be wrapped in `<details>` like above.
|
||||
If NO issues found:
|
||||
```
|
||||
<!-- deepseek-pr-review -->
|
||||
@@ -131,24 +141,25 @@ jobs:
|
||||
```
|
||||
|
||||
STRICT RULES:
|
||||
- Output the markdown table ONLY — no extra text, no summaries, no praise
|
||||
- Each issue: file path with line, severity (🔴 High / 🟡 Medium / 🟢 Low), one-line description with fix suggestion
|
||||
- 2 sentences max per issue
|
||||
- Output ONLY the `<!-- deepseek-pr-review -->` marker followed by the review content — no extra text, no summaries, no praise
|
||||
- Each finding MUST be a `<details>` block with severity emoji in the `<summary>`: `🔴 High`, `🟡 Medium`, `🟢 Low`
|
||||
- The summary line format: `🔴 High: \`path/file:line\`` (severity + file path with line)
|
||||
- Inside each `<details>` block: one or two sentences describing the issue and fix
|
||||
- Max 10 issues, sorted by severity (high first)
|
||||
- If existing review body shows resolved issues, append a "### Resolved" section with ~~strikethrough~~
|
||||
- DO NOT number items outside the table column
|
||||
- DO NOT use "1.", "2." at the start of each issue — use the table's `#` column instead
|
||||
- Maintain a blank line between `</details>` and the next `<details>`
|
||||
ENDINSTRUCTIONS
|
||||
)
|
||||
|
||||
JSON_BODY=$(jq -n \
|
||||
SYSTEM_PROMPT="You are a senior code reviewer. Review the following PR diff for bugs, security issues, and performance problems. Skip style suggestions, documentation, and trivial improvements. Be concise — 2 sentences max per issue. Max 10 issues. Prioritize by severity."
|
||||
|
||||
RESPONSE=$(jq -n \
|
||||
--arg model "deepseek-chat" \
|
||||
--arg sys "$SYSTEM_PROMPT" \
|
||||
--arg instructions "$INSTRUCTIONS" \
|
||||
--arg pr_number "$PR_NUMBER" \
|
||||
--arg pr_commits "$PR_COMMITS" \
|
||||
--arg diff_truncated "$DIFF_TRUNCATED" \
|
||||
--arg existing_body "$EXISTING_BODY" \
|
||||
--rawfile instructions /tmp/instructions.txt \
|
||||
--rawfile pr_commits /tmp/pr_commits.json \
|
||||
--rawfile diff_truncated /tmp/pr_diff_truncated.txt \
|
||||
--rawfile existing_body /tmp/existing_body.txt \
|
||||
'{
|
||||
model: $model,
|
||||
messages: [
|
||||
@@ -162,18 +173,16 @@ jobs:
|
||||
],
|
||||
temperature: 0.0,
|
||||
max_tokens: 8192
|
||||
}')
|
||||
}' | curl -s https://api.deepseek.com/v1/chat/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
|
||||
-d @-)
|
||||
|
||||
RESPONSE=$(curl -s https://api.deepseek.com/v1/chat/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
|
||||
-d "$JSON_BODY")
|
||||
|
||||
REVIEW_BODY=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // empty')
|
||||
REVIEW_BODY=$(printf '%s' "$RESPONSE" | jq -r '.choices[0].message.content // empty')
|
||||
|
||||
if [ -z "$REVIEW_BODY" ]; then
|
||||
echo "DeepSeek API returned empty response"
|
||||
echo "Error: $(echo "$RESPONSE" | jq -r '.error.message // "unknown error"')"
|
||||
echo "Error: $(printf '%s' "$RESPONSE" | jq -r '.error.message // "unknown error"')"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user