Skip to content

fix(safe-outputs): fall back to env vars when create_report_incomplete_issue omits workflow_name - #46400

Merged
pelikhan merged 3 commits into
mainfrom
copilot/aw-fix-report-incomplete-payload
Jul 18, 2026
Merged

fix(safe-outputs): fall back to env vars when create_report_incomplete_issue omits workflow_name#46400
pelikhan merged 3 commits into
mainfrom
copilot/aw-fix-report-incomplete-payload

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

create_report_incomplete_issue messages emitted by agents lack deployment-time metadata (workflow_name, workflow_source_url, run_url) because agents don't have that context. The handler was doing a hard fail on missing workflow_name, silently dropping the incomplete-run report and turning the safe_outputs job red.

Changes

missing_issue_helpers.cjs

  • Resolve workflow_name, workflow_source_url, and run_url from the message first, then fall back to env vars available in the safe_outputs job:
    • workflow_nameGH_AW_WORKFLOW_NAME
    • workflow_source_urlGH_AW_WORKFLOW_SOURCE_URL
    • run_url → constructed from GITHUB_SERVER_URL/GITHUB_REPOSITORY/GITHUB_RUN_ID
  • Hard fail on workflow_name only if both the message field and the env var fallback are empty
// Before
const workflowName = message.workflow_name;  // hard fail if missing

// After
const workflowName = message.workflow_name || process.env.GH_AW_WORKFLOW_NAME || "";
const workflowSourceURL = message.workflow_source_url || process.env.GH_AW_WORKFLOW_SOURCE_URL || "";
const runUrl = message.run_url || (GITHUB_SERVER_URL && GITHUB_REPOSITORY && GITHUB_RUN_ID
  ? `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`
  : "");

missing_issue_helpers.test.cjs

  • beforeEach now clears all relevant env vars to prevent test bleed
  • Added 4 regression tests covering env var fallback for each field, and confirming message values take precedence over env vars
  • Updated existing missing-workflow_name test to assert failure only when both message field and env var are absent

@github-actions

Copy link
Copy Markdown
Contributor

Hey @copilot-swe-agent 👋 — thanks for picking up the report_incomplete workflow_name fix! This PR is still a WIP with no code changes yet. Once implementation lands, please make sure to:

  • Add tests — a regression test asserting every report_incomplete payload carries workflow_name would be valuable per the issue spec.
  • Update the description — add a summary of the approach taken once work begins.

If you'd like a hand, you can assign this prompt to your coding agent:

Fix the report_incomplete safe output to inject workflow_name from the GITHUB_WORKFLOW environment variable at emit time, or make workflow_name optional server-side with a fallback. Add a compile/validation test asserting every report_incomplete payload carries workflow_name. See issue #46376 for full context.

Generated by ✅ Contribution Check · 58.1 AIC · ⌖ 11.6 AIC · ⊞ 6.2K ·

…report_incomplete_issue messages

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing workflow name in report_incomplete payload fix(safe-outputs): fall back to env vars when create_report_incomplete_issue omits workflow_name Jul 18, 2026
Copilot AI requested a review from pelikhan July 18, 2026 09:48
@pelikhan
pelikhan marked this pull request as ready for review July 18, 2026 09:49
Copilot AI review requested due to automatic review settings July 18, 2026 09:49

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.

Pull request overview

Adds deployment-context fallbacks so incomplete-report safe outputs are not rejected when agents omit workflow metadata.

Changes:

  • Falls back to safe-output job environment metadata.
  • Adds regression tests for fallback and precedence behavior.
  • Regenerates the auto-upgrade cron schedule.
Show a summary per file
File Description
actions/setup/js/missing_issue_helpers.cjs Resolves missing workflow metadata from environment variables.
actions/setup/js/missing_issue_helpers.test.cjs Tests metadata fallback and precedence.
.github/workflows/agentic-auto-upgrade.yml Changes the weekly auto-upgrade schedule.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread .github/workflows/agentic-auto-upgrade.yml Outdated
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address the unresolved review feedback below, and rerun checks once the branch is up to date.

Unresolved review feedback:

Generated by 👨‍🍳 PR Sous Chef · 16.7 AIC · ⌖ 5.67 AIC · ⊞ 6K ·
Comment /souschef to run again

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #46400 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

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

The fix is correct and well-tested. Field resolution is properly moved before validation, env var fallbacks follow the right precedence (message → env var → empty string), and the 4 new tests cover each fallback path plus the message-takes-precedence case. The beforeEach cleanup prevents test bleed. No blocking issues.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 9.2 AIC · ⌖ 4.92 AIC · ⊞ 5K

@github-actions github-actions Bot mentioned this pull request Jul 18, 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.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — the fix is correct and well-tested.

📋 Key Themes & Highlights

Positive Highlights

  • ✅ Root cause addressed: env var fallbacks applied before the hard-fail guard
  • ✅ Solid regression tests: 4 new cases covering fallback priority and each optional field
  • beforeEach env cleanup prevents test bleed
  • ✅ Existing failure test updated to reflect the new two-pronged guard

Minor Suggestion

  • The runUrl ternary is a long one-liner (see inline comment) — consider splitting or extracting a helper for readability

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 20 AIC · ⌖ 4.42 AIC · ⊞ 6.7K
Comment /matt to run again

// Resolve fields from message, falling back to environment variables for fields
// that the agent may not know (e.g. workflow_name is not part of the agent's context).
const workflowName = message.workflow_name || process.env.GH_AW_WORKFLOW_NAME || "";
const workflowSource = message.workflow_source || "";

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] The runUrl ternary is a single long line — hard to scan during future edits.

💡 Suggested refactor
const runUrl =
  message.run_url ||
  (process.env.GITHUB_SERVER_URL &&
   process.env.GITHUB_REPOSITORY &&
   process.env.GITHUB_RUN_ID
    ? `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
    : "");

Or extract a small helper buildRunUrl() alongside the other field resolutions to keep the handler body scannable.

@copilot please address this.

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

🔎 Code quality review by PR Code Quality Reviewer · 26.8 AIC · ⌖ 4.34 AIC · ⊞ 5.6K
Comment /review to run again

Comments that could not be inline-anchored

actions/setup/js/missing_issue_helpers.cjs:28

Unreadable one-liner: the runUrl ternary is ~160 chars on a single line, making it hard to review and a merge-conflict magnet.

<details>
<summary>💡 Suggested refactor</summary>

const runUrl =
  message.run_url ||
  (process.env.GITHUB_SERVER_URL &amp;&amp;
   process.env.GITHUB_REPOSITORY &amp;&amp;
   process.env.GITHUB_RUN_ID
    ? `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
    : &quot;&quot;);

Splitting across lines makes the three…

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 71/100 — Acceptable

Analyzed 21 test(s): 19 design, 2 implementation, 0 violation(s).

📊 Metrics (21 tests)
Metric Value
Analyzed 21 (Go: 0, JS: 21)
✅ Design 19 (90%)
⚠️ Implementation 2 (10%)
Edge/error coverage 10 (48%)
Duplicate clusters 0
Inflation YES (89 test lines / 11 prod lines ≈ 8:1)
🚨 Violations 0
Test File Classification Issues
should return error when workflow_name is missing missing_issue_helpers.test.cjs:84 design_test
should fall back to GH_AW_WORKFLOW_NAME env var missing_issue_helpers.test.cjs:93 design_test
should prefer message workflow_name over env var missing_issue_helpers.test.cjs:113 design_test
should fall back to GH_AW_WORKFLOW_SOURCE_URL missing_issue_helpers.test.cjs:133 design_test
should construct run_url from GitHub env vars missing_issue_helpers.test.cjs:153 design_test
should return error when items field is missing missing_issue_helpers.test.cjs:175 design_test
should return error when items array is empty missing_issue_helpers.test.cjs:183 design_test
should return error when items field is not an array missing_issue_helpers.test.cjs:191 design_test
should skip processing when max count is reached missing_issue_helpers.test.cjs:201 design_test
should allow higher max counts missing_issue_helpers.test.cjs:221 design_test
should use defaultTitlePrefix when no config.title_prefix missing_issue_helpers.test.cjs:243 implementation_test Internal search query assertion
should use config.title_prefix when provided missing_issue_helpers.test.cjs:257 implementation_test Internal search query assertion
should add comment to existing issue missing_issue_helpers.test.cjs:273 design_test
should include rendered item in comment body missing_issue_helpers.test.cjs:298 design_test
should create a new issue when no existing issue found missing_issue_helpers.test.cjs:317 design_test
should apply labels when configured missing_issue_helpers.test.cjs:334 design_test
should apply array labels when configured missing_issue_helpers.test.cjs:348 design_test
should always apply defaultLabels from options missing_issue_helpers.test.cjs:362 design_test
should merge defaultLabels with config.labels missing_issue_helpers.test.cjs:376 design_test
should deduplicate labels missing_issue_helpers.test.cjs:390 design_test edge case
should return error result when GitHub API throws missing_issue_helpers.test.cjs:406 design_test
⚠️ Flagged Tests (2)

should use defaultTitlePrefix when no config.title_prefix provided (missing_issue_helpers.test.cjs:243) — implementation_test. Asserts that the GitHub search query q parameter contains the title prefix string. This tests internal call formatting rather than a user-observable outcome. The behavioral contract is sound but the assertion binds to the internal API call format.

should use config.title_prefix when provided (missing_issue_helpers.test.cjs:257) — implementation_test. Same pattern: verifying the raw search query string is an implementation detail. Consider asserting on the created issue title for stronger behavioral coverage.

Test inflation note: The test file added 89 lines against 11 production lines (≈8:1 ratio). This is informational — the PR expands coverage of pre-existing behavior alongside the new env-var fallback feature. Coverage quality is good.

Verdict

Passed. 10% implementation tests (threshold: 30%). No guideline violations. The five new tests covering env-var fallback behaviour (GH_AW_WORKFLOW_NAME, GH_AW_WORKFLOW_SOURCE_URL, GITHUB_SERVER_URL/GITHUB_REPOSITORY/GITHUB_RUN_ID) directly target the PR's behavioral contract and provide strong regression protection.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🧪 Test quality analysis by Test Quality Sentinel · 37.8 AIC · ⌖ 9.06 AIC · ⊞ 7K ·
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: 71/100. 10% implementation tests (threshold: 30%). No violations.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

The cron schedule was inadvertently changed from "11 4 * * 6" to "21 3 * * 5"
as an unintended side effect of running make recompile. This change is unrelated
to the safe-outputs env-var fallback fix. Reverting to the original value.

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address the unresolved review feedback below, and rerun checks once the branch is up to date.

Unresolved review feedback:...

Reverted the unintended cron schedule change in agentic-auto-upgrade.yml — restored from "21 3 * * 5" back to "11 4 * * 6" in commit $(git -C /home/runner/work/gh-aw/gh-aw log --oneline -1 --format=%h). The change was an accidental side effect of running make recompile and is unrelated to the safe-outputs fallback fix.

Copilot AI requested a review from gh-aw-bot July 18, 2026 10:28
@pelikhan
pelikhan merged commit c6c667e into main Jul 18, 2026
1 check failed
@pelikhan
pelikhan deleted the copilot/aw-fix-report-incomplete-payload branch July 18, 2026 10:29
Copilot stopped work on behalf of pelikhan due to an error July 18, 2026 10:29
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.14

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw-failures] [aw-fix] P1: report_incomplete safe output rejected — "Missing required field: workflow_name"

4 participants