Repository navigation
Add error handling in "Get linked issue body" step to distinguish between "no linked issue" and API failures #9
Description
Add error handling in "Get linked issue body" step to distinguish between "no linked issue" and API failures
What
In .github/workflows/_ai-pr-review.yml, the "Get linked issue body" step currently uses || true to swallow all errors from the pipeline:
ISSUE_NUM=$(gh pr view ${{ github.event.pull_request.number }} --json body,title \
| jq -r '[.title, .body] | join(" ")' \
| python3 -m cicaid_devtools.lib.linked_issue || true)This needs to be refactored to distinguish between:
- Valid outcome: No linked issue found (the
python3 -m cicaid_devtools.lib.linked_issuecommand exits with a specific code or output indicating no linked issue) - Error:
gh pr vieworjqfails (e.g., authentication failure, network issue, malformed response)
Why
The current implementation masks real failures. If gh pr view fails due to a token issue or API error, ISSUE_NUM will be empty and the step will proceed as if "No linked issue found" — hiding an authentication or infrastructure problem. This makes debugging difficult and could lead to incorrect workflow behavior (e.g., skipping a review that should have happened, or proceeding without context that should have been available).
How
- Separate the commands: Split the pipeline into distinct steps or use explicit error handling:
- First, fetch the PR data with
gh pr viewand check its exit code - Then, run the
python3 -m cicaid_devtools.lib.linked_issuecommand separately
- First, fetch the PR data with
- Check exit codes explicitly: Instead of
|| true, capture exit codes and handle them:- If
gh pr viewfails, fail the step with a clear error message - If
python3 -m cicaid_devtools.lib.linked_issueexits with a "no linked issue" code, setISSUE_NUMto empty and continue - If
python3 -m cicaid_devtools.lib.linked_issueexits with an unexpected error, fail the step
- If
- Add error output: Use
GITHUB_OUTPUTorecho "::error::"to provide clear diagnostics when failures occur
Files Affected
.github/workflows/_ai-pr-review.yml
Constraints
- Must not break the existing behavior when no linked issue is found (the workflow should continue normally)
- Must not introduce new dependencies or require changes to the
cicaid_devtoolspackage - Must maintain compatibility with the existing
continue-on-errorpattern used elsewhere in the workflow - Out of scope: fixing the misleading condition in the "Fail if provider did not approve" step (separate issue)
LLM tier
Sonnet — This requires moderate design judgment to properly handle exit codes and error paths without breaking existing behavior. It's a single-file change but involves non-trivial logic restructuring.
Success looks like
- When
gh pr viewfails (e.g., invalid token), the step fails with a clear error message indicating the API call failed - When no linked issue exists, the step succeeds with
ISSUE_NUMempty and the workflow continues as before - When
python3 -m cicaid_devtools.lib.linked_issueencounters an unexpected error, the step fails with diagnostic information - The workflow behaves identically to before for all valid scenarios (linked issue found, no linked issue)
Failure looks like
- The step still swallows errors from
gh pr vieworjq - The workflow fails when no linked issue is found (regression)
- Error messages are unclear or don't indicate which command failed
- The change introduces shell syntax errors or breaks the existing pipeline structure
Follow-up from AI review of PR #3.
Implementation notes
FILES: .github/workflows/_ai-pr-review.yml
DONE: Refactor the "Get linked issue body" step to explicitly check exit codes from gh pr view and the python3 -m cicaid_devtools.lib.linked_issue command, failing the step on API/command errors while preserving the current behavior of continuing with an empty ISSUE_NUM when no linked issue exists.
Activity
leonarduk commentedon Sep 6, 2026
Revision bound exhausted — needs human help.
Last diff:
Last test output:
malformed coder output: no '=== FILE: ... === / === MODE: ... === / === END FILE ===' sections found in coder output
leonarduk commentedon Sep 6, 2026
FILES: .github/workflows/_ai-pr-review.yml
DONE: Refactor the "Get linked issue body" step to explicitly check exit codes from
gh pr viewand thepython3 -m cicaid_devtools.lib.linked_issuecommand, failing the step on API/command errors while preserving the current behavior of continuing with an emptyISSUE_NUMwhen no linked issue exists.leonarduk commentedon Sep 6, 2026
VERDICT: NEEDS_INFO
MISSING:
python3 -m cicaid_devtools.lib.linked_issuefor "no linked issue" but doesn't specify what that exit code is or how to detect it (e.g., exit code 0 with empty output vs. a specific non-zero code). The implementation needs to know the exact contract of this command.continue-on-errorpattern used elsewhere in the workflow" but doesn't specify which steps use this pattern or how the new error handling should interact with it. Need to see the current workflow structure to understand the context.gh pr viewoutput should be saved to a variable/file for reuse, or if the pipeline should be restructured to avoid re-fetching data. Need clarity on the desired command structure.