Skip to content

compilerenv: remove constructor panic to satisfy custom Go lint#43044

Merged
pelikhan merged 2 commits into
mainfrom
copilot/lint-go
Jul 2, 2026
Merged

compilerenv: remove constructor panic to satisfy custom Go lint#43044
pelikhan merged 2 commits into
mainfrom
copilot/lint-go

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

The CGO workflow failed in golint-custom because pkg/workflow/compilerenv/manager.go used a panic in library code (New(nil)). This change removes that failure mode and keeps constructor behavior safe under nil injection.

  • Problem surfaced by CI

    • New(getenv EnvGetter) panicked on nil, violating the repository lint rule: “avoid panic in library code; return an error instead”.
  • Behavior change

    • New(nil) now falls back to os.Getenv instead of panicking.
    • This preserves a valid Manager instance even when caller injection is omitted.
  • Test updates

    • Replaced panic expectation with a behavioral test that verifies New(nil) reads process env values via ResolveDefaultMaxTurns.
func New(getenv EnvGetter) *Manager {
	if getenv == nil {
		getenv = os.Getenv
	}
	return &Manager{getenv: getenv}
}

Copilot AI and others added 2 commits July 2, 2026 21:49
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 fix(compilerenv): avoid panic in New when getter is nil compilerenv: remove constructor panic to satisfy custom Go lint Jul 2, 2026
Copilot AI requested a review from pelikhan July 2, 2026 21:54
@pelikhan pelikhan marked this pull request as ready for review July 2, 2026 23:33
Copilot AI review requested due to automatic review settings July 2, 2026 23:33
@pelikhan pelikhan merged commit 1d3b7bd into main Jul 2, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/lint-go branch July 2, 2026 23:34

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

This PR updates the compilerenv package constructor to avoid panicking on nil injection (to satisfy the repo’s “no panic in library code” lint rule), and adjusts tests accordingly. It also includes a broad regeneration of workflow .lock.yml files that bumps the gh-aw-firewall image/tag from 0.27.20 to 0.27.22.

Changes:

  • Replace panic in compilerenv.New(nil) with a safe fallback to os.Getenv.
  • Update the unit test to assert the new New(nil) behavior via ResolveDefaultMaxTurns.
  • Regenerate multiple workflow lockfiles, updating embedded firewall image/tag/version references (0.27.200.27.22).
Show a summary per file
File Description
pkg/workflow/compilerenv/manager.go Removes constructor panic; New(nil) now falls back to os.Getenv.
pkg/workflow/compilerenv/manager_test.go Updates test coverage to validate the new nil-constructor behavior.
.github/workflows/test-workflow.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/smoke-opencode.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/smoke-crush.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/smoke-antigravity.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/firewall.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/example-permissions-warning.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/daily-max-ai-credits-test.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/daily-malicious-code-scan.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/codex-github-remote-mcp-test.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/bot-detection.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/agentic-token-optimizer.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.
.github/workflows/ace-editor.lock.yml Regenerated lockfile with firewall image/tag bump to 0.27.22.

Review details

Tip

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

  • Files reviewed: 41/260 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment on lines 26 to 30
// New creates a Manager using the provided EnvGetter for environment lookups.
func New(getenv EnvGetter) *Manager {
if getenv == nil {
panic("compilerenv: getenv must not be nil")
getenv = os.Getenv
}
@@ -1,5 +1,5 @@
# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"5814ea2bda11902a25a3e75c0189405073fc82b9712830686467627cff58c7e9","body_hash":"3a147e0e12646872769eb5643fbcb96fc4f9aab3c7b23bf999dade4ea82bd684","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.68","copilot-sdk":"1.0.5"}}
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GH_AW_OTEL_GRAFANA_AUTHORIZATION","GH_AW_OTEL_GRAFANA_ENDPOINT","GH_AW_OTEL_SENTRY_AUTHORIZATION","GH_AW_OTEL_SENTRY_ENDPOINT","GITHUB_TOKEN"],"actions":[{"repo":"actions/cache/restore","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/cache/save","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/checkout","sha":"9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0","version":"v7.0.0"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.27.20"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.20"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.27.20"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.32","digest":"sha256:63e46b56dfd70895a701b6fc6dd0189e11e2d875f327f1781e81b31848735477","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.3.32@sha256:63e46b56dfd70895a701b6fc6dd0189e11e2d875f327f1781e81b31848735477"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b","pinned_image":"ghcr.io/github/gh-aw-node@sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b"},{"image":"ghcr.io/github/github-mcp-server:v1.5.0","digest":"sha256:e25564dccc9110a70a77b9df560cbde11aa392fcb5f08b9abe5c4ebc6d146ea4","pinned_image":"ghcr.io/github/github-mcp-server:v1.5.0@sha256:e25564dccc9110a70a77b9df560cbde11aa392fcb5f08b9abe5c4ebc6d146ea4"}]}
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GH_AW_OTEL_GRAFANA_AUTHORIZATION","GH_AW_OTEL_GRAFANA_ENDPOINT","GH_AW_OTEL_SENTRY_AUTHORIZATION","GH_AW_OTEL_SENTRY_ENDPOINT","GITHUB_TOKEN"],"actions":[{"repo":"actions/cache/restore","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/cache/save","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/checkout","sha":"9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0","version":"v7.0.0"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.27.22"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.22"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.27.22"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.32","digest":"sha256:63e46b56dfd70895a701b6fc6dd0189e11e2d875f327f1781e81b31848735477","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.3.32@sha256:63e46b56dfd70895a701b6fc6dd0189e11e2d875f327f1781e81b31848735477"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b","pinned_image":"ghcr.io/github/gh-aw-node@sha256:529d02eb970b1161aa25c593a9c3df57fdfad5a8add328cb3b6eccef66f3183b"},{"image":"ghcr.io/github/github-mcp-server:v1.5.0","digest":"sha256:e25564dccc9110a70a77b9df560cbde11aa392fcb5f08b9abe5c4ebc6d146ea4","pinned_image":"ghcr.io/github/github-mcp-server:v1.5.0@sha256:e25564dccc9110a70a77b9df560cbde11aa392fcb5f08b9abe5c4ebc6d146ea4"}]}
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.

3 participants