You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
jsonmarshalignoredeerror FN: bare-call json.Unmarshal(data, &v) (ExprStmt) discards the error but is never inspected — only As
[Content truncated due to length] #39982
jsonmarshalignoredeerror only inspects assignment statements, so it catches the explicit-blank discard forms (_ = json.Unmarshal(...), v, _ := json.Marshal(...)) but completely misses the bare expression-statement formjson.Unmarshal(data, &v) / json.Marshal(x), where every return — including the error — is discarded implicitly. The implicit-discard form is the most common mistake the linter exists to prevent, yet it silently passes a CI-enforced check (.github/workflows/cgo.yml:1123), giving false assurance that all json.Marshal/Unmarshal error-discards are caught.
nodeFilter:= []ast.Node{(*ast.AssignStmt)(nil)} // <-- ExprStmt never visited
A bare call such as json.Unmarshal(data, &v) is an *ast.ExprStmt, not an *ast.AssignStmt, so the Preorder walk never sees it.
Evidence the pattern is used in-repo
Bare json.Unmarshal(...) calls already appear in the codebase:
pkg/parser/json_path_locator_test.go:141
pkg/cli/logs_awinfo_backward_compat_test.go:173 and :182
pkg/workflow/dependabot_test.go:607
These are test files, and CI runs the linter with -test=false (cgo.yml:1123), so they don't trip enforcement today. The gap is that any production pkg/ bare-call would escape silently — a latent false negative in an enforced linter.
What is already correct
Package identity is resolved properly through TypesInfo in isJSONFunc (:75-93, *types.PkgName.Imported().Path() == "encoding/json"), so this is purely a node-coverage gap, not a matching gap.
Recommended fix
Add (*ast.ExprStmt)(nil) to the node filter and handle the bare-call case: when an ExprStmt's X is a *ast.CallExpr to json.Marshal/json.Unmarshal, report it (a bare call discards all returns, including the error). Keep the existing AssignStmt branch for the explicit-blank forms.
Activity
github-actions commentedon Jun 25, 2026
This issue was automatically closed because it expired on 2026-06-25T05:25:30.310Z.