publish.sh: PR-creation and push failures are silently swallowed #112

Closed
opened 2026-07-27 15:28:47 +02:00 by ffaerber · 11 comments
Owner

Follow-up to #111 with the exact fix location.

Root cause

Both silent-failure paths live in .gitea/workflows/scripts/publish.sh, in the dev-agent
PR-open path near the end of the file:

  1. PR-create failure is swallowed. After the curl -X POST "$API/pulls" call, if it fails
    (url stays empty), the script does this:

    [ -z "$url" ] && { echo "PR open/lookup failed for $br — posting reply on issue instead"; post "$(printf '%s%s' "$reply" "$activity")"; exit 0; }
    

    The echo only reaches the Actions run log. The comment posted to the issue is the agent's
    normal reply with no mention that a PR should exist, no branch name, no HTTP status, no
    error body. This is the exact scenario in #111ai/issue-12 had a real commit pushed but no
    PR, and nothing in the issue said why.

  2. git push failure is discarded outright, not just under-reported:

    git push origin "HEAD:$BRANCH" || true
    

    If the push fails, ahead (computed later from origin/main..origin/$br) can read 0, and
    the script takes the "no changes — plan only" branch, actively misreporting a push failure as
    "nothing to do."

Requested fix

  • On PR-create failure: capture the HTTP status and Gitea's .message from the response, and
    post a distinct ⚠️ comment on the issue naming the branch and the error — not the agent's
    plain reply.
  • On git push failure: don't swallow with || true — detect it and post a similarly loud
    comment instead of falling through to the "no changes" path.

Keep the rest of the control flow (the post / prpost / trig helpers, the 🤖 loop-guard
marker) untouched — this is a narrow fix to the two error paths above.

Follow-up to #111 with the exact fix location. ## Root cause Both silent-failure paths live in `.gitea/workflows/scripts/publish.sh`, in the dev-agent PR-open path near the end of the file: 1. **PR-create failure is swallowed.** After the `curl -X POST "$API/pulls"` call, if it fails (`url` stays empty), the script does this: ```sh [ -z "$url" ] && { echo "PR open/lookup failed for $br — posting reply on issue instead"; post "$(printf '%s%s' "$reply" "$activity")"; exit 0; } ``` The `echo` only reaches the Actions run log. The comment posted to the issue is the agent's normal reply with **no mention that a PR should exist**, no branch name, no HTTP status, no error body. This is the exact scenario in #111 — `ai/issue-12` had a real commit pushed but no PR, and nothing in the issue said why. 2. **`git push` failure is discarded outright**, not just under-reported: ```sh git push origin "HEAD:$BRANCH" || true ``` If the push fails, `ahead` (computed later from `origin/main..origin/$br`) can read `0`, and the script takes the "no changes — plan only" branch, actively misreporting a push failure as "nothing to do." ## Requested fix - On PR-create failure: capture the HTTP status and Gitea's `.message` from the response, and post a distinct `⚠️` comment on the issue naming the branch and the error — not the agent's plain reply. - On `git push` failure: don't swallow with `|| true` — detect it and post a similarly loud comment instead of falling through to the "no changes" path. Keep the rest of the control flow (the `post` / `prpost` / `trig` helpers, the `🤖` loop-guard marker) untouched — this is a narrow fix to the two error paths above.
Member

Plan for #112 — narrow fix to two silent-failure paths in .gitea/workflows/scripts/publish.sh.

Scope (one file, two locations):

  1. PR-create failure (the [ -z "$url" ] && ... block): replace the silent echo with captured HTTP status + Gitea's .message from the curl response, then post a distinct ⚠️ comment naming the branch and the error — instead of the agent's plain reply.
  2. git push failure (the git push origin "HEAD:$BRANCH" || true line): drop the || true, detect non-zero exit, and post a similarly loud ⚠️ comment instead of falling through to the "no changes" branch.

Untouched: the post / prpost / trig helpers, the 🤖 loop-guard marker, and the fix-attempt trigger template+regex (the latter must stay pinned together per the learnings, but neither error path we're editing touches that template).

Who: @junior. Single-file, well-scoped, shell error-handling fix. No agent additions, no heredoc edits, no trigger-gate changes — the agent-addition learnings don't apply. Script is critical but the diff is narrow and isolated to two known blocks.

@ffaerber ready to start building? reply yes to proceed.

details

🔧 0 tool calls · in 10332 · out 1994 tokens · subscription · model ollama-cloud/minimax-m3:cloud

(no tool calls — text-only reply)

tokens — input 10332 (fresh 10332 · cache 0w / 0r) · output 1994 · reasoning 0 · subscription

Plan for #112 — narrow fix to two silent-failure paths in `.gitea/workflows/scripts/publish.sh`. **Scope (one file, two locations):** 1. **PR-create failure** (the `[ -z "$url" ] && ...` block): replace the silent `echo` with captured HTTP status + Gitea's `.message` from the curl response, then post a distinct `⚠️` comment naming the branch and the error — instead of the agent's plain reply. 2. **`git push` failure** (the `git push origin "HEAD:$BRANCH" || true` line): drop the `|| true`, detect non-zero exit, and post a similarly loud `⚠️` comment instead of falling through to the "no changes" branch. **Untouched:** the `post` / `prpost` / `trig` helpers, the `🤖` loop-guard marker, and the fix-attempt trigger template+regex (the latter must stay pinned together per the learnings, but neither error path we're editing touches that template). **Who:** @junior. Single-file, well-scoped, shell error-handling fix. No agent additions, no heredoc edits, no trigger-gate changes — the agent-addition learnings don't apply. Script is critical but the diff is narrow and isolated to two known blocks. @ffaerber ready to start building? reply yes to proceed. <details> <summary>details</summary> 🔧 0 tool calls · in 10332 · out 1994 tokens · subscription · model ollama-cloud/minimax-m3:cloud _(no tool calls — text-only reply)_ <sub>tokens — input 10332 (fresh 10332 · cache 0w / 0r) · output 1994 · reasoning 0 · **subscription**</sub> </details> <!-- 🤖 agent reply — do not trigger -->
Author
Owner

@pm yes, go ahead.

@pm yes, go ahead.
Member

Handing off to @junior.

details

🔧 0 tool calls · in 10735 · out 88 tokens · subscription · model ollama-cloud/minimax-m3:cloud

(no tool calls — text-only reply)

tokens — input 10735 (fresh 10735 · cache 0w / 0r) · output 88 · reasoning 0 · subscription

Handing off to @junior. <details> <summary>details</summary> 🔧 0 tool calls · in 10735 · out 88 tokens · subscription · model ollama-cloud/minimax-m3:cloud _(no tool calls — text-only reply)_ <sub>tokens — input 10735 (fresh 10735 · cache 0w / 0r) · output 88 · reasoning 0 · **subscription**</sub> </details> <!-- 🤖 agent reply — do not trigger -->
Member

@junior please proceed with issue #112 per my plan above.

@junior please proceed with issue #112 per my plan above.
Member

🔨 Building on branch ai/issue-112 — I'll open a PR when it's ready.

🔨 Building on branch [`ai/issue-112`](https://git.ffaerber.duckdns.org/gitea/agents/src/branch/ai/issue-112) — I'll open a PR when it's ready. <!-- 🤖 agent reply — do not trigger -->
Member

@pm — PR #113 is ready for review (issue #112).

@pm — PR #113 is ready for review (issue #112).
Member

Acknowledged — handing PR #113 to @qa for review against the plan in this thread (two narrow edits in .gitea/workflows/scripts/publish.sh: PR-create failure gets a loud ⚠️ comment with status + .message; git push failure stops being swallowed and also gets a loud ⚠️ instead of falling through to the "no changes" path). Helpers / loop-guard / fix-attempt template+regex must stay untouched.

details

🔧 0 tool calls · in 10944 · out 270 tokens · subscription · model ollama-cloud/minimax-m3:cloud

(no tool calls — text-only reply)

tokens — input 10944 (fresh 10944 · cache 0w / 0r) · output 270 · reasoning 0 · subscription

Acknowledged — handing PR #113 to @qa for review against the plan in this thread (two narrow edits in `.gitea/workflows/scripts/publish.sh`: PR-create failure gets a loud `⚠️` comment with status + `.message`; `git push` failure stops being swallowed and also gets a loud `⚠️` instead of falling through to the "no changes" path). Helpers / loop-guard / fix-attempt template+regex must stay untouched. <details> <summary>details</summary> 🔧 0 tool calls · in 10944 · out 270 tokens · subscription · model ollama-cloud/minimax-m3:cloud _(no tool calls — text-only reply)_ <sub>tokens — input 10944 (fresh 10944 · cache 0w / 0r) · output 270 · reasoning 0 · **subscription**</sub> </details> <!-- 🤖 agent reply — do not trigger -->
Member

@qa please review PR #113 for issue #112 — put your recommendations on the PR, or approve.

@qa please review PR #113 for issue #112 — put your recommendations on the PR, or approve.
Member

Reviewed PR #113 — looks good.

✅ Reviewed PR #113 — looks good. <!-- 🤖 agent reply — do not trigger -->
Member

@pm — I have reviewed and approved PR #113 (issue #112). Over to you.

@pm — I have reviewed and approved PR #113 (issue #112). Over to you.
Member

PR #113 is reviewed and ready to merge, @ffaerber.

details

🔧 0 tool calls · in 0 · out 211 tokens · subscription · model ollama-cloud/minimax-m3:cloud

(no tool calls — text-only reply)

tokens — input 0 (fresh 0 · cache 0w / 0r) · output 211 · reasoning 0 · subscription

PR #113 is reviewed and ready to merge, @ffaerber. <details> <summary>details</summary> 🔧 0 tool calls · in 0 · out 211 tokens · subscription · model ollama-cloud/minimax-m3:cloud _(no tool calls — text-only reply)_ <sub>tokens — input 0 (fresh 0 · cache 0w / 0r) · output 211 · reasoning 0 · **subscription**</sub> </details> <!-- 🤖 agent reply — do not trigger -->
Sign in to join this conversation.
4 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gitea/agents#112