Skip to content

Replace any bool-or-expression fields with *TemplatableBool in workflow step and safe-outputs config - #51097

Merged
pelikhan merged 9 commits into
mainfrom
copilot/code-quality-reuse-templatable-bool
Aug 7, 2026
Merged

Replace any bool-or-expression fields with *TemplatableBool in workflow step and safe-outputs config#51097
pelikhan merged 9 commits into
mainfrom
copilot/code-quality-reuse-templatable-bool

Conversation

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This change removes two remaining any-typed bool-or-expression fields and aligns them with the existing TemplatableBool model. It also eliminates ad-hoc runtime type switching in conclusion env generation by using typed accessors.

  • Type unification

    • WorkflowStep.ContinueOnError changed from any*TemplatableBool.
    • SafeOutputsConfig.ReportFailureAsIssue changed from any*TemplatableBool.
    • Category-array behavior for report-failure-as-issue remains represented via ReportFailureAsIssueCategories / ReportFailureAsIssueExcludedCategories.
  • Parsing + serialization updates

    • Step map conversion now normalizes continue-on-error bool/string-expression inputs into *TemplatableBool.
    • Step map output now emits literal true/false as booleans and expressions as strings.
    • Safe-outputs global parsing now materializes report-failure-as-issue as *TemplatableBool while preserving include/exclude category extraction.
  • Conclusion policy env handling cleanup

    • Replaced manual bool|string|[]any branching with TemplatableBool-based evaluation for GH_AW_FAILURE_REPORT_AS_ISSUE.
    • Category filters are still emitted only when semantically enabled.
type WorkflowStep struct {
    // before: ContinueOnError any
    ContinueOnError *TemplatableBool `yaml:"continue-on-error,omitempty"`
}

type SafeOutputsConfig struct {
    // before: ReportFailureAsIssue any
    ReportFailureAsIssue *TemplatableBool `yaml:"report-failure-as-issue,omitempty"`
}

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 10.2 AIC · ⊞ 8.4K ·
Comment /souschef to run again

Copilot AI and others added 2 commits August 7, 2026 14:44
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor ContinueOnError and ReportFailureAsIssue fields to use TemplatableBool Replace any bool-or-expression fields with *TemplatableBool in workflow step and safe-outputs config Aug 7, 2026
Copilot AI requested a review from pelikhan August 7, 2026 14:56
@pelikhan
pelikhan marked this pull request as ready for review August 7, 2026 16:37
Copilot AI balanced review requested due to automatic review settings August 7, 2026 16:37
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Design Decision Gate 🏗️. Review the logs for details.

No ADR enforcement needed: PR does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (65 additions detected).

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

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.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Test Quality Sentinel. Review the logs for details.

No new test functions were added or modified in this PR. This is a refactoring PR that updates existing test fixtures and assertions to work with the new TemplatableBool type signature. The PR modified 4 existing test files (compiler_safe_outputs_config_test.go, notify_comment_test.go, safe_outputs_import_test.go, step_types_test.go) but did not add any new behavioral tests. Since no new test coverage was introduced, Test Quality Sentinel skips scoring and reports no action needed.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Matt Pocock Skills Reviewer. Review the logs for details.

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

Unifies bool-or-expression fields under TemplatableBool, updating parsing, serialization, and conclusion-policy generation.

Changes:

  • Types ContinueOnError and ReportFailureAsIssue.
  • Preserves boolean, expression, and category-filter behavior.
  • Updates tests and regenerated workflow output.
Show a summary per file
File Description
pkg/workflow/step_types.go Types and converts step error handling.
pkg/workflow/step_types_test.go Updates step conversion tests.
pkg/workflow/safe_outputs_import_test.go Updates imported-setting assertions.
pkg/workflow/safe_outputs_config_types.go Types the reporting setting.
pkg/workflow/safe_outputs_config_global.go Parses typed reporting values.
pkg/workflow/notify_comment_test.go Tests reporting environment generation.
pkg/workflow/notify_comment_conclusion_helpers.go Removes runtime type assertions.
pkg/workflow/compiler_safe_outputs_config_test.go Updates configuration parsing tests.
.github/workflows/smoke-cursor.lock.yml Synchronizes generated workflow output.

Review details

Tip

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

  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread pkg/workflow/step_types.go

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

Review: Replace any with *TemplatableBool

The PR correctly unifies ContinueOnError and ReportFailureAsIssue fields under *TemplatableBool. The logic is sound:

  • Nil checks before .String() calls are properly guarded (nil check at line 339 ensures the else branch is only reached with a non-nil pointer)
  • The buildAgentFailureReportingPolicyVars switch correctly initializes shouldIncludeCategoryFilters = true and only sets it to false in the false/expression cases
  • Category filters are preserved correctly for the true case
  • The compareStepValues nil-pointer handling for *TemplatableBool is correct

One minor observation: step_types.go now silently drops non-expression, non-bool strings for continue-on-error (the old code preserved them). This is likely intentional as part of the type narrowing.

No blocking issues found. ✅

Warning

Firewall blocked 1 domain

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

  • proxy.golang.org

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

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 56.1 AIC · ⊞ 5.4K

@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 /codebase-design and /tdd — overall a clean, well-scoped refactor. Requesting 4 targeted improvements before merge.

📋 Key Themes & Highlights

Key Themes

  • Silent discard risk: MapToStep silently drops unrecognised continue-on-error string values with no error or diagnostic
  • Implicit default fragility: The "true" branch in conclusion-policy env generation relies on an implicit default rather than an explicit assignment
  • Test documentation gap: The meaningful behaviour change (string "false" → native bool false in compiled output) is tested but not named or documented as an invariant
  • Minor DRY opportunity: strconv.FormatBool + TemplatableBool(...) construction is now scattered across two files; a shared NewTemplatableBoolFromBool helper would centralise it

Positive Highlights

  • ✅ Eliminates 18-line any-type switch in conclusion-policy generation — the new .String()-based switch is dramatically more readable
  • ✅ Bidirectional serialisation (bool ↔ string ↔ expression) is correctly handled in both ToMap and MapToStep
  • ✅ Tests updated throughout; templatableBoolPtr helper keeps test boilerplate low
  • ✅ Category-array behaviour preserved cleanly via separate fields; the updated comment on ReportFailureAsIssue accurately documents the new contract

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 52.2 AIC · ⊞ 7.1K
Comment /matt to run again

Comments that could not be inline-anchored

pkg/workflow/step_types.go:146

[/codebase-design] Silent discard for unrecognised continue-on-error string values — if a user writes e.g. &quot;yes&quot; or &quot;1&quot;, step.ContinueOnError stays nil and the field is silently dropped from compiled output with no diagnostic.

<details>
<summary>💡 Suggested fix</summary>

Add an else branch that surfaces the unrecognised value as an error:

case string:
    if value == &quot;true&quot; || value == &quot;false&quot; || isExpression(value) {
        templatableValue := TemplatableBool(value)
…

</details>

<details><summary>pkg/workflow/notify_comment_conclusion_helpers.go:348</summary>

**[/codebase-design]** The `&quot;true&quot;` case no longer sets `shouldIncludeCategoryFilters = true` explicitly — it relies on the default value declared two lines up. This is correct today but fragile: if the default changes or a future reviewer adds an early `shouldIncludeCategoryFilters = false` branch before the switch, category filters will silently stop being emitted for the `true` case.

&lt;details&gt;
&lt;summary&gt;💡 Suggested fix&lt;/summary&gt;

Make the intent explicit:

```go
case &quot;true&quot;:
    appendRepor…

</details>

<details><summary>pkg/workflow/step_types_test.go:297</summary>

**[/tdd]** Good catch — this test now asserts `&quot;false&quot;` round-trips as a boolean `false` (not as the string `&quot;false&quot;`). But the previous test at line 290–295 keeps `ContinueOnError: templatableBoolPtr(&quot;false&quot;)` with the expected map containing `&quot;continue-on-error&quot;: false`, while the diff shows the old expected value was `&quot;false&quot;` (a string). This is a meaningful behaviour change; it would benefit from a dedicated test name that documents the invariant: `TestToMap_ContinueOnErrorLiteralEmitsNati</details>

<details><summary>pkg/workflow/safe_outputs_config_global.go:180</summary>

**[/codebase-design]** `strconv.FormatBool` used here for a `bool` case, but `TemplatableBool` is a `string` typedefso the three parsing branches (`bool`, `string`, and implicitly nil) each independently construct `TemplatableBool`. Consider extracting a small helper `newTemplatableBool(v bool) *TemplatableBool` (or `TemplatableBoolFromBool`) to keep construction consistent across all call sites and avoid the inline `strconv` import.

&lt;details&gt;
&lt;summary&gt;💡 Suggested helper&lt;/summary&gt;

```go
f…

</details>

@pelikhan

pelikhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Ran the pr-finisher pass and pushed d5f3abf. Local validation passes; CI is stale after the agent push and needs a maintainer re-trigger before merge.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please triage this PR, refresh the branch if possible, and run the pr-finisher skill before handing back to maintainers.

Unresolved review threads to re-check:

Run context: https://github.com/github/gh-aw/actions/runs/31204567664

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 10.2 AIC · ⊞ 8.4K ·
Comment /souschef to run again

@pelikhan
pelikhan merged commit 89edb9a into main Aug 7, 2026
22 of 24 checks passed
@pelikhan
pelikhan deleted the copilot/code-quality-reuse-templatable-bool branch August 7, 2026 18:29
Copilot stopped work on behalf of gh-aw-bot due to an error August 7, 2026 18:29
Copilot AI requested a review from gh-aw-bot August 7, 2026 18:29
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Triage Result

Category: refactor · Risk: medium · Priority: medium (score 58/100 — impact 22, urgency 12, quality 24)
Recommended action: fast_track

Notes: Type-safety refactor (any → *TemplatableBool) across 10 files, +79/-56. AI reviewer approved (github-actions[bot]); some reviewer comments outstanding. CI shows all jobs skipped/cancelled — needs a fresh CI run before merge. Already labeled needs-review.

Generated by 🔧 PR Triage Agent · auto · 31.2 AIC · ⌖ 2.44 AIC · ⊞ 7.9K ·

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.1

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.

[Code Quality] Reuse TemplatableBool for ContinueOnError and ReportFailureAsIssue fields instead of any

4 participants