Skip to content

Skip add_labels when no triggering issue or PR exists - #65619

Merged
pelikhan merged 3 commits into
mainfrom
copilot/deep-report-fix-safe-outputs-job
Oct 4, 2026
Merged

pelikhan merged 3 commits into
mainfrom
copilot/deep-report-fix-safe-outputs-job

Conversation

Copilot AI commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Safe-output jobs failed after successfully creating an issue or discussion because an incidental add_labels result had no triggering issue or PR to target.

  • Behavior: Treat add_labels with the default triggering target and no issue/PR context as skipped. Explicit target errors remain fatal.
  • Regression coverage: Verify the handler marks the operation skipped and the manager does not treat it as fatal alongside a successful write.
{ type: "add_labels", success: false, skipped: true }

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix safe-outputs job hard failure despite item success Skip add_labels when no triggering issue or PR exists Oct 4, 2026
Copilot AI requested a review from pelikhan October 4, 2026 15:39
@pelikhan
pelikhan marked this pull request as ready for review October 4, 2026 16:03
Copilot AI balanced review requested due to automatic review settings October 4, 2026 16:03
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Lean already. Ship.

Generated by Ponytail Reviewer for #65619

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Hard target-resolution failures are currently ignored, bypassing fail-closed target validation.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Updates add_labels to skip default triggering targets when no issue or pull request context exists.

Changes:

  • Adds soft-skip target resolution.
  • Adds handler and manager regression coverage.
File Description
actions/​setup/​js/​add_labels.cjs Adds triggering-context resolution and skip handling.
actions/​setup/​js/​add_labels.test.cjs Tests issue, PR, and missing-context behavior.
actions/​setup/​js/​safe_output_handler_manager.test.cjs Verifies skipped labels are nonfatal.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread actions/setup/js/add_labels.cjs Outdated
Comment on lines 297 to 302
const targetResult = resolveTarget({ targetConfig: target, item: message, context, itemType: HANDLER_TYPE, supportsPR: true });
if (!targetResult.success && targetResult.shouldFail === false) {
core.warning(targetResult.error);
return { success: false, skipped: true, reason: targetResult.error, error: targetResult.error };
}
itemNumber = triggeringItemNumber;

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.

Fixed in 45b8bd3: add_labels now returns hard resolveTarget failures and uses its validated issue/PR number, preventing forwarded string-number contexts from reaching the API.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-10-04T16:06:11Z
review_event: COMMENT
top_themes:
  - no blocking issues in targeted safe-output skip handling
  - regression coverage added for skipped add_labels results
files_reviewed:
  - actions/setup/js/add_labels.cjs
  - actions/setup/js/add_labels.test.cjs
  - actions/setup/js/safe_output_handler_manager.test.cjs
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 42.1 AIC · ⌖ 7.04 AIC · ⊞ 19.4K · ◷
Comment /review to run again

@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.

Verdict

No blocking issues found in the changed lines.

Review notes

I checked the new add_labels triggering-context skip path and the added manager regression coverage. The handler now converts the missing issue/PR context into a skipped result instead of a fatal failure, and the manager test covers the exact mixed-success case that motivated the change. I did not find a correctness or maintainability regression in the patched lines that would justify blocking the PR.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 42.1 AIC · ⌖ 7.04 AIC · ⊞ 19.4K
Comment /review to run again

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

✅ Test Quality Score: 100/100 — Excellent

Analyzed 2 test(s): 2 design, 0 implementation. Zero violations.

📊 Metrics (2 tests)
Metric Value
Analyzed 2 (JS: 2)
✅ Design Tests 2 (100%)
⚠️ Implementation Tests 0 (0%)
Edge/error coverage 2/2 (100%)
Duplicate clusters 0
Test inflation No
🚨 Violations 0
✅ Test Classification
Test File Classification Behavioral Value
"should skip when the triggering context has no issue or pull request" add_labels.test.cjs:748 Design test HIGH — Verifies skip behavior when add_labels has no issue/PR context
"does not fail the job when a successful write has an unrelated add_labels skip" safe_output_handler_manager.test.cjs:414 Design test HIGH — Verifies job doesn't fail on mixed success + skip results

Verdict

✅ Passed. 0% implementation tests (threshold: 30%). Both new tests enforce design contracts: the skip behavior and the job-outcome handling. No violations detected.

🧪 Test quality analysis by Test Quality Sentinel · copilot · haiku45 · 26.4 AIC · ⌖ 9.28 AIC · ⊞ 8.2K · ◷
Comment /review to run again

@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.

✅ Test Quality Sentinel: 100/100. 0% implementation tests (threshold: 30%). Both new tests enforce design contracts without violations.

🧪 Test quality analysis by Test Quality Sentinel · copilot · haiku45 · 26.4 AIC · ⌖ 9.28 AIC · ⊞ 8.2K
Comment /review to run again

@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.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /codebase-design to this targeted fix for issue #65599 (add_labels hard-failing the safe-outputs job when there's no triggering issue/PR). The core fix is sound and well-tested, but the same root cause is left unfixed in two sibling handlers.

📋 Key Themes & Highlights

Key Themes

  • Incomplete bug fix scope: remove_labels.cjs and replace_label.cjs share the exact target === "triggering" code path that was just patched in add_labels.cjs, but they still return a bare {success:false} (no skipped:true) in the no-context case — meaning they'll continue to hard-fail the safe-outputs job via the same partitionFailureResults path described in #65599. Their existing tests (remove_labels.test.cjs:389) still assert the old, broken behavior ("No issue/PR number available" without skipped), confirming this wasn't addressed.
  • Minor redundancy: add_labels.cjs now calls resolveInvocationContext(context) twice in the same code path (once directly, once inside resolveTarget) — not incorrect, but worth simplifying since resolveInvocationContext can throw on invalid workflow_dispatch/repository_dispatch repo overrides.

Positive Highlights

  • ✅ Good regression coverage: both the handler-level skip behavior (add_labels.test.cjs) and the manager-level "skip doesn't fail alongside a success" scenario (safe_output_handler_manager.test.cjs) are tested, directly mirroring the issue's reproduction steps.
  • ✅ Correctly reuses the existing resolveTarget/shouldFail convention already established in update_handler_factory.cjs, keeping the skip semantics consistent across handlers rather than inventing a new convention.
  • ✅ Minimal, surgical diff that doesn't touch unrelated logic.

Requesting changes to extend the same fix to remove_labels.cjs and replace_label.cjs (or extract a shared helper) so the regression class is fully closed rather than fixed for one of three affected handlers.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 116.2 AIC · ⌖ 14.7 AIC · ⊞ 10K
Comment /matt to run again

if (!targetResult.success) return targetResult;
itemNumber = targetResult.number ?? triggeringItemNumber;
} else if (target === "triggering") {
const targetResult = resolveTarget({ targetConfig: target, item: message, context, itemType: HANDLER_TYPE, supportsPR: true });

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.

[/codebase-design] resolveInvocationContext(context) is already called two lines above (line 287) to get triggeringItemNumber, and resolveTarget calls it again internally. Besides the redundant work, resolveInvocationContext can throw (e.g. checkAllowedRepo validation failures for workflow_dispatch/repository_dispatch overrides) — the first call at line 287 is unguarded, so that failure mode predates this PR, but adding a second call site here doubles the chance of an uncaught throw bubbling out of the handler instead of being converted into a clean {success:false} result.

💡 Suggested simplification

Since effectiveContext from line 287 and the context resolveTarget recomputes internally should be equivalent, consider passing the already-resolved effectiveContext/triggeringItemNumber into the skip check directly (e.g. a lighter-weight isTriggeringContextAvailable(effectiveContext, { supportsPR: true }) check) rather than invoking the full resolveTarget resolution path a second time just to read shouldFail.

@copilot please address this.

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.

Fixed in 45b8bd3: the triggering path now uses resolveTarget's validated number and context directly, removing the duplicate invocation-context resolution. The same skip behavior now covers remove_labels and replace_label.

@pelikhan

pelikhan commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
pelikhan merged commit 4bb7964 into main Oct 4, 2026
12 checks passed
@pelikhan
pelikhan deleted the copilot/deep-report-fix-safe-outputs-job branch October 4, 2026 19:31
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.91.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[deep-report] Safe-outputs job hard-fails despite the sole configured item succeeding (PR Triage Agent, Auto-Triage Issues)

3 participants