Skip to content

Fix issue-to-PR handoff when created issue output is empty#603

Closed
strawgate wants to merge 4 commits intomainfrom
fix/issue-to-pr-handoff-investigation
Closed

Fix issue-to-PR handoff when created issue output is empty#603
strawgate wants to merge 4 commits intomainfrom
fix/issue-to-pr-handoff-investigation

Conversation

@strawgate
Copy link
Collaborator

@strawgate strawgate commented Mar 8, 2026

Summary

  • investigate Trigger Text Auditor run #22816943792 and confirm issue creation succeeded while the chained create_pr_from_issue job was skipped
  • add a generated resolve_created_issue job for remediation workflows that:
    • uses needs.run.outputs.created_issue_number when present
    • falls back to searching bot-authored issues containing the current actions/runs/ URL in the issue body
  • wire create_pr_from_issue to consume the resolved issue number output from this resolver job
  • update scripts/dogfood.sh so regenerated trigger workflows keep this resolver-and-handoff behavior

Why this fixes it

In the observed run, safe-output-items contained a successful create_issue entry, but the run reusable-workflow output used by trigger chaining was empty. The fallback resolver makes the handoff robust to that output gap.

Test plan

  • regenerate triggers via ./scripts/dogfood.sh
  • make lint-workflows
  • verify generated trigger changes in:
    • .github/workflows/trigger-text-auditor.yml
    • .github/workflows/trigger-docs-patrol.yml
    • .github/workflows/trigger-framework-best-practices.yml
  • verify the generator change in scripts/dogfood.sh that appends and wires the remediation chain

The body of this PR is automatically managed by the Trigger Update PR Body workflow.

Resolve the created issue number from run outputs first, then fall back to searching issues by current run URL in body so chained create-pr jobs still run when created_issue_number output is unexpectedly empty.
Replace issue-search fallback with direct extraction of create_issue number from same-run safe-output-items artifact, so issue-to-PR chaining relies only on deterministic workflow outputs.
@github-actions github-actions bot added the medium_boom Medium PR blast radius; likely benefits from human review label Mar 8, 2026
if [ -z "$number" ]; then
number="$(gh issue list \
--repo "$REPOSITORY" \
--search "in:body \"actions/runs/$RUN_ID\" author:github-actions[bot] is:issue" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] Fallback issue lookup is restricted to a single author

The resolver only searches for issues authored by github-actions[bot], but issue creation in these workflows uses $\{\{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}. When GH_AW_GITHUB_TOKEN is set to a different bot/user token, the issue is created by that actor, this query returns nothing, and create_pr_from_issue is skipped even though an issue exists.

Suggested change
--search "in:body \"actions/runs/$RUN_ID\" author:github-actions[bot] is:issue" \
--search "in:body \"actions/runs/$RUN_ID\" is:issue" \

@coderabbitai
Copy link

coderabbitai bot commented Mar 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7a5f745d-dcc8-42ee-b089-ff08e5230861

📥 Commits

Reviewing files that changed from the base of the PR and between 861b0ad and ff7fbc9.

📒 Files selected for processing (4)
  • .github/workflows/trigger-docs-patrol.yml
  • .github/workflows/trigger-framework-best-practices.yml
  • .github/workflows/trigger-text-auditor.yml
  • scripts/dogfood.sh

📝 Walkthrough

Walkthrough

This change updates multiple GitHub Actions workflows and the helper script to split a single-step flow into two stages: a new resolve_created_issue job is added that computes and exposes created_issue_number and created_issue_url (via a gh call) as job outputs; existing create_pr_from_issue jobs now depend on resolve_created_issue, consume ${{ needs.resolve_created_issue.outputs.created_issue_number }} as target-issue-number, gate execution on that output being non-empty, and receive an added secret EXTRA_COMMIT_GITHUB_TOKEN. Some workflows add actions: read permission and the dogfood script was updated to emit the new resolve block when generating workflows.

Possibly related PRs

  • elastic/ai-github-actions PR 480: Modifies trigger workflows and the dogfood generation to wire through the EXTRA_COMMIT_GITHUB_TOKEN secret and update generated trigger jobs.
  • elastic/ai-github-actions PR 601: Updates scripts/dogfood.sh and generated workflows to inject actions: read permissions and restructure the resolve_created_issue / create_pr_from_issue flow.
  • elastic/ai-github-actions PR 335: Edits scripts/dogfood.sh in ways that overlap with this change to the generated resolve_created_issue block and workflow generation logic.
✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/issue-to-pr-handoff-investigation
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

Add created_issue_url alongside created_issue_number in generated resolve_created_issue outputs so downstream jobs can consume stable issue metadata directly from workflow outputs.
Keep created_issue_number sourced from the originating workflow output and pass it into resolve_created_issue only for URL enrichment, avoiding duplicate number propagation through the resolver job.
@strawgate strawgate closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

medium_boom Medium PR blast radius; likely benefits from human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant