Lint Issue Group 2: Type Assertion Safety & Deferred Lock Fixes
Summary
40 lint violations spanning type assertion safety (29 issues) and deferred mutex unlock errors (11 issues). These are low-level safety issues affecting core packages.
Issue Details
Category: Safety (panics, deadlocks)
Affected Packages: pkg/parser/, pkg/linters/, pkg/workflow/, pkg/cli/, pkg/agentdrain/, pkg/console/
Root Causes:
- Unchecked type assertions that can panic if type is wrong
- Non-deferred mutex unlocks that don't protect against deadlocks on early return or panic
Type Assertion Violations (29 issues)
Examples:
pkg/parser/virtual_fs.go:76,90 - Unchecked *FrontmatterResult assertions
pkg/workflow/dispatch_repository.go:164 - Unchecked map[string]any assertion
pkg/workflow/repository_features_validation.go:185,212 - Unchecked *RepositoryFeatures assertions
pkg/linters/excessivefuncparams/excessivefuncparams.go:41 - Unchecked *ast.FuncDecl assertion
pkg/cli/jsonworkflow_to_markdown.go:448,455 - Unchecked string assertions
Fix Pattern:
// WRONG
value := x.(Type) // Panics if x is not Type
// CORRECT
value, ok := x.(Type)
if !ok {
return fmt.Errorf("expected Type, got %T", x)
}
Deferred Mutex Unlock Violations (11 issues)
Examples:
pkg/agentdrain/coordinator.go:115 - Mutex Lock without defer
pkg/agentdrain/miner.go:118,137,148 - Multiple mutex issues
pkg/console/spinner.go:130,159,175,195 - Spinner mutex locks
pkg/cli/compile_watch.go:189 - Watch mode mutex issue
pkg/cli/docker_images.go:104 - Docker mutex issue
Fix Pattern:
// WRONG
mu.Lock()
// ... code that might return or panic ...
mu.Unlock()
// CORRECT
mu.Lock()
defer mu.Unlock()
// ... code ...
Expected Outcome
All 40 violations resolved by:
- Adding two-value form checks for all type assertions
- Adding defer statements immediately after all mutex locks
- No behavioral changes; only safety improvements
- All fixes verified with
make golint-custom
Remediation Checklist
Skill Guidance
Use error-pattern-safety SKILL for:
- Safe error pattern matching guidelines
- Type assertion safety considerations
- Mutex locking safety patterns
Notes
- Type assertion safety: Panics can crash workflows silently
- Deferred unlock safety: Prevents deadlocks when functions return early or panic
- These changes are pure safety improvements with no behavior change
Generated by 🧌 LintMonster · haiku45 162.7K · ◷
Lint Issue Group 2: Type Assertion Safety & Deferred Lock Fixes
Summary
40 lint violations spanning type assertion safety (29 issues) and deferred mutex unlock errors (11 issues). These are low-level safety issues affecting core packages.
Issue Details
Category: Safety (panics, deadlocks)
Affected Packages:
pkg/parser/,pkg/linters/,pkg/workflow/,pkg/cli/,pkg/agentdrain/,pkg/console/Root Causes:
Type Assertion Violations (29 issues)
Examples:
pkg/parser/virtual_fs.go:76,90- Unchecked*FrontmatterResultassertionspkg/workflow/dispatch_repository.go:164- Uncheckedmap[string]anyassertionpkg/workflow/repository_features_validation.go:185,212- Unchecked*RepositoryFeaturesassertionspkg/linters/excessivefuncparams/excessivefuncparams.go:41- Unchecked*ast.FuncDeclassertionpkg/cli/jsonworkflow_to_markdown.go:448,455- UncheckedstringassertionsFix Pattern:
Deferred Mutex Unlock Violations (11 issues)
Examples:
pkg/agentdrain/coordinator.go:115- Mutex Lock without deferpkg/agentdrain/miner.go:118,137,148- Multiple mutex issuespkg/console/spinner.go:130,159,175,195- Spinner mutex lockspkg/cli/compile_watch.go:189- Watch mode mutex issuepkg/cli/docker_images.go:104- Docker mutex issueFix Pattern:
Expected Outcome
All 40 violations resolved by:
make golint-customRemediation Checklist
grep -r "x\.( " pkg/ | grep -v testokcheckgrep -n "\.Lock()" pkg/agentdrain/*.go pkg/console/*.go pkg/cli/compile_watch.go pkg/cli/docker_images.godefer mu.Unlock()immediately after the Lock() linemake golint-customand verify all 40 violations are gonemake test-unitto ensure no regressionsSkill Guidance
Use error-pattern-safety SKILL for:
Notes