Skip to content

Add classification-labels input and add-labels safe output to Issue Triage - #1030

Merged
fr4nc1sc0-r4m0n merged 6 commits into
mainfrom
copilot/add-classification-labels-input
Apr 30, 2026
Merged

fr4nc1sc0-r4m0n merged 6 commits into
mainfrom
copilot/add-classification-labels-input

Conversation

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor
  • Add classification-labels input and add-labels safe output to Issue Triage
  • Create gh-aw-fragments/safe-output-add-labels.md reusable fragment
  • Refactor gh-aw-dependency-review.md to import the new fragment
  • Update README.md / docs/ and example.yml
  • Fix: add GH_AW_AGENT_OUTPUT env var to safe-output-add-labels.md fragment env: block
  • Fix: regenerate lock files via make compile (sync with fragment fix)
  • Fix: upgrade actions/github-script from v7 to v9 in safe-output-add-labels.md; recompile lock files

…ssue-triage

Agent-Logs-Url: https://github.com/elastic/ai-github-actions/sessions/e09ad63a-2941-4150-8412-17cb4b5a6094

Co-authored-by: fr4nc1sc0-r4m0n <215478872+fr4nc1sc0-r4m0n@users.noreply.github.com>
Copilot AI changed the title [WIP] Add classification-labels input parameter to issue triage Add classification-labels input and add-labels safe output to Issue Triage Apr 27, 2026
Copilot AI requested a review from fr4nc1sc0-r4m0n April 27, 2026 11:27
@fr4nc1sc0-r4m0n

Copy link
Copy Markdown
Contributor

@copilot could make sense to create a fragment for the add-labels safe output to reuse this?

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot could make sense to create a fragment for the add-labels safe output to reuse this?

Done — created gh-aw-fragments/safe-output-add-labels.md (546a3a9) that encapsulates the add-labels: max: 3 config and the Pre-sanitize allowlist-filtering step. Both gh-aw-dependency-review.md and gh-aw-issue-triage.md now import this fragment instead of inlining the logic.

@fr4nc1sc0-r4m0n
fr4nc1sc0-r4m0n marked this pull request as ready for review April 27, 2026 11:45
@github-actions github-actions Bot added the medium_boom Medium PR blast radius; likely benefits from human review label Apr 27, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requesting changes: the new shared safe-output-add-labels fragment does not wire GH_AW_AGENT_OUTPUT into the sanitizer step, so allowlist filtering can be skipped depending on caller environment.


What is this? | From workflow: Trigger PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

- name: Pre-sanitize labels from input allowlist
uses: actions/github-script@v7
env:
CLASSIFICATION_LABELS: ${{ inputs.classification-labels }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GH_AW_AGENT_OUTPUT is used by this script (const outputPath = process.env.GH_AW_AGENT_OUTPUT;) but it isn’t wired into this step’s env, so this sanitizer can silently no-op when the variable isn’t already present in the job environment.

That defeats the allowlist filtering (classification-labels) and can let unfiltered add_labels operations reach safe-output processing.

Please pass the output path explicitly here (for example from steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT) so the fragment is self-contained and consistently enforces the allowlist.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot address this comment #1030 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot apply the changes proposed in this comment #1030 (comment)

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot could make sense to create a fragment for the add-labels safe output to reuse this?

Already done — gh-aw-fragments/safe-output-add-labels.md (546a3a9) encapsulates the add-labels: max: 3 config and the Pre-sanitize allowlist-filtering step. Both gh-aw-dependency-review.md and gh-aw-issue-triage.md import this fragment instead of inlining the logic.

@fr4nc1sc0-r4m0n

Copy link
Copy Markdown
Contributor

@copilot Address this issue in the fragment:

file: .github/workflows/gh-aw-fragments/safe-output-add-labels.md
line: 9
severity: HIGH
title: Pre-sanitize allowlist can silently no-op because required output-path env is not wired
description: The sanitizer reads process.env.GH_AW_AGENT_OUTPUT but this fragment only sets CLASSIFICATION_LABELS. If GH_AW_AGENT_OUTPUT is not injected by the caller, the step exits early and allowlist filtering is skipped entirely.
evidence: env: lacks GH_AW_AGENT_OUTPUT (line 9), while script immediately uses it (line 13) and returns on missing value (lines 14–17). This leaves add_labels unfiltered even when classification-labels is empty/invalid.
suggestion: Add GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} in the fragment env (or fail hard if missing).

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Address this issue in the fragment:

file: .github/workflows/gh-aw-fragments/safe-output-add-labels.md
...

Fixed in db3cc4a. Added GH_AW_AGENT_OUTPUT: ${{ steps.setup-agent-output-env.outputs.GH_AW_AGENT_OUTPUT }} to the env: block in both the fragment (safe-output-add-labels.md) and the compiled gh-aw-dependency-review.lock.yml. The issue triage lock already had it wired correctly.

@fr4nc1sc0-r4m0n

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix the failing check https://github.com/elastic/ai-github-actions/actions/runs/24994619728/job/73188335080?pr=1030

Fixed in 7b96fff. The CI was failing because the lock files were out of sync — I had manually edited them instead of regenerating via make compile. Installed the gh-aw compiler and ran make compile to correctly regenerate gh-aw-dependency-review.lock.yml, gh-aw-issue-triage.lock.yml, and trigger-issue-triage.yml from the updated fragment source.

max: 3
steps:
- name: Pre-sanitize labels from input allowlist
uses: actions/github-script@v7

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot use v9 here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 0fa6131 — updated safe-output-add-labels.md to actions/github-script@v9 and recompiled the lock files. The v7 pin is now gone from both gh-aw-dependency-review.lock.yml and gh-aw-issue-triage.lock.yml.

@fr4nc1sc0-r4m0n

Copy link
Copy Markdown
Contributor

@copilot I want to modify the gh-aw-issue-triage agentic workflow to receive a custom ephemeral token to be used in the pull request labeling safe output to allow events being triggered by this labeling action.

Copilot AI commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

@copilot I want to modify the gh-aw-issue-triage agentic workflow to receive a custom ephemeral token to be used in the pull request labeling safe output to allow events being triggered by this labeli...

This is already implemented in the current PR. The optional GH_AW_GITHUB_TOKEN secret is declared in gh-aw-issue-triage.md and is wired as the github-token for the safe outputs handler in the compiled lock file (github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}). When provided (e.g. a GitHub App token), labels applied via add_labels will use that token, allowing downstream label-triggered workflows to fire. When omitted, it falls back to GITHUB_TOKEN. The docs at docs/workflows/gh-agent-workflows/issue-triage.md explain this explicitly.

@fr4nc1sc0-r4m0n

Copy link
Copy Markdown
Contributor

It's working fine:

I think we can merge this one @v1v

@fr4nc1sc0-r4m0n fr4nc1sc0-r4m0n left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@fr4nc1sc0-r4m0n
fr4nc1sc0-r4m0n enabled auto-merge (squash) April 30, 2026 12:34
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.

Issue Triage allows issue labelling

3 participants