Repository navigation
Description
manualpathconcat: compound-assignment += form of manual "/" path concatenation is never detected
Problem
manualpathconcat (pkg/linters/manualpathconcat/manualpathconcat.go) only matches the specific nested-BinaryExpr shape produced by X + "/" + Y (parsed as (X + "/") + Y, see matchSlashSeparator, lines 86-105). Its node filter is []ast.Node{(*ast.BinaryExpr)(nil)} (line 43) — it never inspects ast.AssignStmt.
The idiomatic compound form path += "/" + suffix (equivalent to path = path + "/" + suffix) is represented in the AST as an AssignStmt{Tok: token.ADD_ASSIGN} whose RHS is just "/" + suffix — a two-operand BinaryExpr where X is the "/" literal itself, not a nested BinaryExpr. matchSlashSeparator requires bin.X to be a *ast.BinaryExpr (line 92), so this RHS can never match, regardless of the compound-assignment context. The implicit path + prefix that += contributes is structurally invisible to the analyzer.
Evidence — real production site
pkg/workflow/checkout_config_parser.go:316:
absPath := "$GITHUB_WORKSPACE"
if !isRoot {
absPath += "/" + relPath // manual "/" concat via += — NOT flagged
}This is exactly the pattern the linter exists to catch (manual "/" concatenation building a path-like string) but it produces zero diagnostics today. A repo-wide check (grep -rn '+= "/"' pkg --include="*.go") confirms this is the only current +=-form hit, but the blind spot is structural, not incidental — any future x += "/" + y anywhere in pkg/ will silently bypass the linter forever.
This is the mirror image of a previously-fixed sibling bug: stringsconcatloop (#49046) originally matched only ADD_ASSIGN and missed the plain x = x + y form. Here manualpathconcat matches only the plain nested-BinaryExpr form and misses ADD_ASSIGN.
Impact
- False negatives: any
+=-based manual path join is invisible, undermining the linter's stated purpose (double-slash bugs, missingClean()-style normalization, non-portable separators). - The gap is silent — no diagnostic, no
nolintneeded, no test failure — so it will keep missing new occurrences as the codebase grows. manualpathconcatis not currently wired into.github/workflows/cgo.yml'sLINTER_FLAGS(not yet CI-enforced), so this is a good moment to close the detection gap before enforcement is turned on, avoiding a second silent blind spot at enforcement time.
Recommendation
Add an *ast.AssignStmt case (or extend the node filter to include it) that:
- Matches
Tok == token.ADD_ASSIGNwith a singleLhs/singleRhs. - Checks whether
Rhs[0]is"/" + Y(aBinaryExprwhoseXoperand is the slash literal) — i.e. reuseisSlashLiteralagainstbin.Xdirectly instead of requiringbin.Xto itself be aBinaryExpr. - Reports using
Lhs[0]as the effective "left" path segment, mirroring the message format already used for theBinaryExprcase (filepath.Join(<lhs>, <rhs>)).
Validation checklist
- New testdata case:
absPath += "/" + relPathproduces the expected diagnostic. - Existing
BinaryExpr-chain testdata cases still pass unchanged. -
pkg/workflow/checkout_config_parser.go:316now flagged (or fixed +nolint'd if the team decides$GITHUB_WORKSPACEis a shell-expanded template string rather than a real filesystem path and intentionally exempt). - Re-run analyzer across
pkg/to confirm no other+=-form manual joins are newly surfaced.
Effort: Small — single-file change to manualpathconcat.go plus one new testdata case.
Generated by 🤖 Sergo - Serena Go Expert · agent · 155.1 AIC · ⌖ 9.88 AIC · ⊞ 6.8K · ◷
- expires on Aug 29, 2026, 8:09 PM UTC-08:00
Activity
github-actions commentedon Aug 23, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪