Skip to content

Raise error-message compliance for sandbox and workflow run validation paths - #52176

Merged
pelikhan merged 5 commits into
mainfrom
copilot/squad-plan-fix-error-message-compliance-another-one
Aug 12, 2026
Merged

Raise error-message compliance for sandbox and workflow run validation paths#52176
pelikhan merged 5 commits into
mainfrom
copilot/squad-plan-fix-error-message-compliance-another-one

Conversation

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the low-compliance error-message findings from lint-error-messages for the targeted batch by standardizing messages to the repo style: what failed, what is expected, and a concrete example/recovery hint. Changes are limited to message text (plus assertion updates where tests pinned old phrasing), with no control-flow or behavior changes.

  • Targeted files and scope

    • Updated non-compliant messages in:
      • pkg/workflow/sandbox_validation.go
      • pkg/cli/run_workflow_execution.go
      • pkg/cli/project_command.go
      • pkg/cli/add_command.go
    • pkg/workflow/memory_validation_config.go is not present in this checkout; pkg/workflow/repo_memory_validation.go is already compliant and unchanged.
  • Validation-message rewrite patterns applied

    • Reframed terse/negative errors into actionable guidance.
    • Added explicit expected format/value ranges/options.
    • Added concrete usage examples or recovery commands where user-actionable.
    • Preserved %w wrapping and existing error boundaries for operational paths.
  • Notable message classes improved

    • Missing required CLI inputs/flags (--owner, workflow args, --input key=value).
    • Invalid identifier/URL formats (repo slug, project URL parsing).
    • Workflow dispatch preconditions (workflow_dispatch requirement).
    • Sandbox safety checks (blocked host ports, disable-justification requirements, type/length/expression constraints).
    • Internal defensive errors now remain clearly marked as internal while still following template guidance.
  • Test alignment (message-fragment assertions only)

    • Updated affected expectations in:
      • pkg/cli/add_command_test.go
      • pkg/cli/run_workflow_execution_test.go
      • pkg/workflow/sandbox_validation_test.go

Example of the new error style:

return fmt.Errorf(
  "input '%s' is not in key=value format. Expected each --input value as key=value. Example: --input environment=staging",
  input,
)

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 26.3 AIC · ⌖ 6.42 AIC · ⊞ 8.5K ·
Comment /souschef to run again

Copilot AI and others added 2 commits August 11, 2026 23:33
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] Fix error message compliance in workflow files Raise error-message compliance for sandbox and workflow run validation paths Aug 11, 2026
Copilot AI requested a review from pelikhan August 11, 2026 23:43
@pelikhan
pelikhan marked this pull request as ready for review August 12, 2026 00:19
Copilot AI balanced review requested due to automatic review settings August 12, 2026 00:19
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the 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.

Warning

Firewall blocked 1 domain

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

  • api.individual.githubcopilot.com

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

network:
  allowed:
    - defaults
    - "api.individual.githubcopilot.com"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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

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

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 12, 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

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship. PR only rewords error message strings (no new abstractions, dependencies, or control flow); nothing in scope for over-engineering review.

Generated by Ponytail Reviewer for #52176

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

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 28.9 AIC · ⌖ 6.2 AIC · ⊞ 5.4K

Comments that could not be inline-anchored

pkg/workflow/sandbox_validation.go:260

The new message drops the actionable hint to also enable sandbox.agent.legacy-security. The original message told the user to "declare it under services: with a port mapping and enable sandbox.agent.legacy-security". The replacement example shows only a services: block, so users who add the services: block but forget legacy-security will get no further guidance.

Suggested fix – append the missing hint:

return fmt.Errorf(&quot;allow-host-ports value %d maps to blocked service</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

Standardizes CLI and sandbox validation errors with actionable expectations and recovery examples, updating pinned test assertions accordingly.

Changes:

  • Improves sandbox, workflow-run, project, and add-command error messages.
  • Aligns related test assertions with revised wording.
Show a summary per file
File Description
pkg/workflow/sandbox_validation.go Revises sandbox validation errors.
pkg/workflow/sandbox_validation_test.go Updates sandbox error assertions.
pkg/cli/run_workflow_execution.go Revises workflow-run errors.
pkg/cli/run_workflow_execution_test.go Updates workflow-run assertions.
pkg/cli/project_command.go Improves project validation errors.
pkg/cli/add_command.go Improves add-command errors.
pkg/cli/add_command_test.go Updates add-command assertion.

Review details

Tip

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

Suppressed comments (2)

pkg/cli/run_workflow_execution.go:548

  • This points recovery at the generated lock file, although the trigger should be added to the source workflow frontmatter and then compiled. Naming the source and recompilation step avoids directing users toward an edit that will be overwritten.
				return fmt.Errorf("workflow '%s' does not declare a workflow_dispatch trigger, so it cannot be run manually on GitHub Actions. Expected a workflow_dispatch trigger in the lock file. Example: on: workflow_dispatch", workflowName)

pkg/cli/run_workflow_execution.go:621

  • The example passes a generated .lock.yml file, but the run path resolves a source workflow and IsRunnable appends .lock.yml itself (run_workflow_validation.go:25-36). Following this example makes it look for ci.lock.yml.lock.yml; use the workflow name or .md source instead.
		return errors.New("workflow list is empty. Expected at least one workflow file name or numeric workflow ID. Example: gh aw run ci.lock.yml")
  • Files reviewed: 7/7 changed files
  • Comments generated: 5
  • Review effort level: Balanced

Comment thread pkg/workflow/sandbox_validation.go Outdated
for _, port := range ports {
if port < minPort || port > maxPort {
return fmt.Errorf("invalid allow-host-ports value: %d. Expected a TCP port between 1 and 65535. Example: allow-host-ports: [5432]", port)
return fmt.Errorf("allow-host-ports value %d is out of range. Expected a TCP port between 1 and 65535. Example: allow-host-ports: [5432]", port)
Comment thread pkg/workflow/sandbox_validation.go Outdated
}
if service, dangerous := awfDangerousHostPorts[port]; dangerous {
return fmt.Errorf("invalid allow-host-ports value: %d. This port is blocked by AWF as a dangerous port (%s) and cannot be reached via allow-host-ports even in legacy-security mode. To reach a service on this port, declare it under services: with a port mapping and enable sandbox.agent.legacy-security", port, service)
return fmt.Errorf("allow-host-ports value %d maps to blocked service %s. Expected blocked service ports to be removed from allow-host-ports because they remain unreachable there, even with legacy-security. Example:\n# Do not list blocked service ports under allow-host-ports\nservices:\n db:\n image: postgres\n ports: [\"5432:5432\"]", port, service)
Comment thread pkg/cli/run_workflow_execution.go Outdated
Comment thread pkg/cli/run_workflow_execution.go Outdated
}
if !runnable {
return fmt.Errorf("workflow '%s' cannot be run on GitHub Actions - it must have 'workflow_dispatch' trigger", workflowIdOrName)
return fmt.Errorf("workflow '%s' does not declare a workflow_dispatch trigger, so it cannot be run manually on GitHub Actions. Expected a workflow_dispatch trigger in the lock file. Example: on: workflow_dispatch", workflowIdOrName)

if scope == "" {
return projectURLInfo{}, errors.New("invalid project URL: could not find orgs/users segment")
return projectURLInfo{}, errors.New("project URL is missing an 'orgs' or 'users' segment. Expected https://github.com/orgs/<org>/projects/<number> or https://github.com/users/<user>/projects/<number>. Example: https://github.com/users/octocat/projects/123")
@github-actions

Copy link
Copy Markdown
Contributor

Test Quality Sentinel Report 🧪

PR: #52176 — "Raise error-message compliance for sandbox and workflow run validation paths"
Repository: github/gh-aw
Actor: pelikhan

Analysis Summary

Key Finding: No New Test Functions

This PR contains test assertion updates only:

  • ✅ No new func Test* functions added
  • ✅ No new test infrastructure added
  • ✅ No new test files created
  • Only string updates in existing require.ErrorContains() and assert.Contains() assertions

The changes update error message assertions to match new error message copy in the production code:

File Changes
pkg/cli/add_command_test.go 1 assertion updated
pkg/cli/run_workflow_execution_test.go 4 assertions updated
pkg/workflow/sandbox_validation_test.go 3 assertions updated

Classification: Assertion Maintenance

These are test maintenance changes, not new behavioral tests. The existing tests remain valid:

  • All 8 error assertions verify error conditions (non-happy-path coverage)
  • All assertions use require.Error* or assert.Contains with descriptive messages
  • No new logic, mocking, or test inflation introduced

Test Quality Score

Score: N/A — Test Maintenance Only

This PR contains no new test functions and no test infrastructure changes. It is purely assertion maintenance to keep test expectations synchronized with updated error message text. No numeric scoring applies.

Violations Check

No violations detected:

  • No new Go test files missing build tags
  • No new test functions using forbidden mock libraries
  • No test inflation (no new tests added)

Recommendation

APPROVED — This is maintenance work that ensures tests accurately reflect the error messages they are validating. The existing tests continue to verify error conditions correctly.

🧪 Test quality analysis by Test Quality Sentinel · haiku45 · 15.1 AIC · ⌖ 4.21 AIC · ⊞ 7.6K ·
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: Test maintenance only. This PR updates error message assertions to match new error copy in production code. All 8 error assertions verify non-happy-path conditions with descriptive messages. No new test functions, infrastructure, or mock usage. No violations detected.

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

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 32.7 AIC · ⌖ 6.68 AIC · ⊞ 7K
Comment /matt to run again

Comment thread pkg/cli/add_command.go
// Check if GitHub CLI is available
if !isGHCLIAvailable() {
return nil, errors.New("GitHub CLI (gh) is required for PR creation but not available")
return nil, errors.New("GitHub CLI (gh) is not available. Expected gh to be installed and on PATH before using --create-pull-request. Example: brew install gh")

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] Platform-specific install hint — brew install gh is macOS-only and will mislead Windows/Linux users.

💡 Suggestion

Replace with a cross-platform reference:

return nil, errors.New("GitHub CLI (gh) is not available. Expected gh to be installed and on PATH before using --create-pull-request. See: https://cli.github.com/")

The same pattern also appears in run_workflow_execution.go line 87.

@copilot please address this.

return fmt.Errorf("allow-host-ports value %d maps to blocked service %s. Expected blocked service ports to be removed from allow-host-ports because they remain unreachable there, even with legacy-security. Example:\n# Do not list blocked service ports under allow-host-ports\nservices:\n db:\n image: postgres\n ports: [\"5432:5432\"]", port, service)
}
}
return nil

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 new blocked-port error embeds a YAML comment (# Do not list blocked service ports under allow-host-ports) inside the error message string.

💡 Suggestion

YAML comments in error text are confusing outside a YAML context and add noise. Replace with a plain prose sentence:

return fmt.Errorf("allow-host-ports value %d maps to blocked service %s. That port is always unreachable from allow-host-ports, even with legacy-security. Declare the service under services: instead. Example:\nservices:\n  db:\n    image: postgres\n    ports: [\"5432:5432\"]", port, service)

@copilot please address this.

func getSandboxDisableJustification(workflowData *WorkflowData) (string, error) {
if workflowData == nil || workflowData.Features == nil {
return "", errors.New("dangerously-disable-sandbox-agent feature is missing")
return "", errors.New("features block is missing dangerously-disable-sandbox-agent configuration. Expected a non-empty string justification under features when sandbox.agent is false. Example:\nfeatures:\n dangerously-disable-sandbox-agent: \"Temporary migration while hardening container profile\"")

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.

[/tdd] Two error paths — workflowData == nil and workflowData.Features == nil — now emit the same message, making it impossible to distinguish them in tests or logs.

💡 Suggestion

Give each branch a distinct message (they already existed as separate branches before this PR):

if workflowData == nil {
    return "", errors.New("workflow data is nil; cannot read dangerously-disable-sandbox-agent configuration")
}
if workflowData.Features == nil {
    return "", errors.New("features block is missing dangerously-disable-sandbox-agent configuration. ...")
}

This also makes test assertions more precise.

@copilot please address this.

data, ok := response["data"].(map[string]any)
if !ok {
return nil, errors.New("invalid response: missing 'data' field")
return nil, errors.New("response is missing the 'data' field. Expected the GitHub GraphQL mutation payload to include data.createProjectV2.projectV2. Example: run 'gh auth status' to verify token scopes, then retry the command")

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] Three consecutive GraphQL response-field errors share the same message and recovery hint, making them indistinguishable in logs.

💡 Suggestion

Each error already names the missing field. The gh auth status recovery hint is generic and unlikely to help for createProjectV2/projectV2 fields. Consider marking inner checks as internal errors:

return nil, errors.New("response is missing 'data' field (internal error)")
return nil, errors.New("response is missing 'createProjectV2' field (internal error)")
return nil, errors.New("response is missing 'projectV2' field (internal error)")

This keeps the gh auth status hint only at the top-level where it is actionable.

@copilot please address this.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please address the latest review feedback, refresh the branch if GitHub offers it, and run the pr-finisher skill.

Open review items (newest first):

  • github-actions review on 2026-08-12 noted the sandbox host-port validation example now omits the sandbox.agent.legacy-security hint; please preserve that actionable guidance while keeping the error-message format compliant.
  • copilot-pull-request-reviewer noted two message examples may point users at generated .lock.yml workflows instead of the source workflow/frontmatter; please correct the examples so they reference the authoring path.

Please push a follow-up commit and resolve any addressed review threads.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 26.3 AIC · ⌖ 6.42 AIC · ⊞ 8.5K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Triage: PR #52176

Generated by 🔧 PR Triage Agent · auto · 44.5 AIC · ⌖ 2.66 AIC · ⊞ 7.8K ·

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

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please address the latest review feedback, refresh the branch if GitHub offers it, and run the pr-finisher skill.

Open review items (newest first):...

Addressed in 5024851: restored the sandbox.agent.legacy-security: enable hint in the blocked host-port message (and switched the range-check example to port 9000, which isn't in the dangerous-ports list), and updated the gh aw run / workflow_dispatch examples to reference the source workflow name and frontmatter (with a gh aw compile recompile step) instead of the generated .lock.yml.

Copilot AI requested a review from gh-aw-bot August 12, 2026 00:57
@pelikhan
pelikhan merged commit dc44132 into main Aug 12, 2026
@pelikhan
pelikhan deleted the copilot/squad-plan-fix-error-message-compliance-another-one branch August 12, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

4 participants