Skip to content

Fix Go E2E SA5011 nil-deref staticcheck findings#1982

Open
roji wants to merge 2 commits into
mainfrom
roji-fix-go-staticcheck-sa5011
Open

Fix Go E2E SA5011 nil-deref staticcheck findings#1982
roji wants to merge 2 commits into
mainfrom
roji-fix-go-staticcheck-sa5011

Conversation

@roji

@roji roji commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes Node E2E test bug that trips the linter and fails our build.

  • fix Go E2E tests that relied on t.Fatal for nil-flow narrowing in patterns that newer staticcheck flags as possible nil dereferences (SA5011)
  • keep assertions identical while moving dereferences into proven non-nil branches
  • apply the same guard pattern across all currently-flagged go/internal/e2e/*_test.go sites

Validation

  • /tmp/golangci-lint run ./internal/e2e/... --timeout=5m
  • go test ./internal/e2e/... -run '^$'
  • go test ./internal/e2e/... fails in this environment because Copilot CLI binary is not installed; these tests require running npm install in nodejs/ first

Restructure nil checks in Go E2E tests so dereferences stay in the proven non-nil branch. This addresses SA5011 findings from newer golangci-lint/staticcheck without suppressing lint rules or pinning older tools.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1e4710a8-2700-4e51-ae9c-657aa8215080
Copilot AI review requested due to automatic review settings July 14, 2026 15:03
@roji roji requested a review from a team as a code owner July 14, 2026 15:03

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

Fixes Go E2E SA5011 findings by placing pointer dereferences inside statically proven non-nil branches without changing assertions.

Changes:

  • Guard assistant response and RPC result dereferences with else branches.
  • Apply the same nil-flow pattern consistently across flagged E2E tests.
Show a summary per file
File Description
go/internal/e2e/tools_e2e_test.go Guards assistant message access.
go/internal/e2e/system_message_sections_e2e_test.go Guards system-message response access.
go/internal/e2e/rpc_ui_ephemeral_query_e2e_test.go Guards ephemeral query result access.
go/internal/e2e/rpc_server_plugins_e2e_test.go Guards plugin and marketplace pointers.
go/internal/e2e/rpc_server_misc_e2e_test.go Guards users result iteration.
go/internal/e2e/rpc_server_e2e_test.go Guards discovery path pointers.
go/internal/e2e/event_fidelity_e2e_test.go Guards assistant event access.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Medium

@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR only modifies Go E2E test files (go/internal/e2e/*_test.go) to fix staticcheck SA5011 nil-dereference warnings by moving post-nil-check logic into else branches.

No cross-SDK consistency issues found. The changes:

  • Are entirely internal to Go test code
  • Do not modify any public API surface
  • Are Go-specific (fixing a Go static analysis warning)
  • Do not introduce any new features that would need to be mirrored in other SDKs

The fix pattern (if x == nil { t.Fatal(...) } else { ... use x ... }) is idiomatic Go and doesn't have an equivalent concern in other language test suites.

Generated by SDK Consistency Review Agent for issue #1982 · sonnet46 435.2K ·

@roji roji enabled auto-merge July 14, 2026 15:08
Resolve PR conflict state by updating the branch to the latest main and taking the upstream resolved versions in the previously conflicting Go E2E files.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1e4710a8-2700-4e51-ae9c-657aa8215080
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.

2 participants