Problem
According to CLAUDE.md, the project uses github.com/go-playground/validator/v10 for struct validation. However, several public structs currently lack validation tags, which can lead to runtime panics when invalid instances are created.
Current Issues
-
BootstrapEntry struct (bootstrap/bootstrap.go:23-26) lacks validation tags:
type BootstrapEntry struct {
Identity model.Identity
LookupTable core.MutableLookupTable
}
Users can create invalid BootstrapEntry instances with nil lookup tables, leading to potential panics at runtime.
-
Missing validation enforcement - No systematic way to ensure new structs include appropriate validation tags
Impact
- Runtime safety: Without validation tags, invalid structs can be created and cause panics
- Developer experience: Errors occur at runtime instead of at construction time
- Code quality: Inconsistent validation patterns across the codebase
Proposed Solution
1. Add Validation Tags to Existing Structs
Identify and add validation tags to all public structs that should be validated:
type BootstrapEntry struct {
Identity model.Identity `validate:"required"`
LookupTable core.MutableLookupTable `validate:"required"`
}
Note: If model.Identity and core.MutableLookupTable are value types (not pointers), document why validation isn't needed or if zero-value is acceptable.
2. Create Validation Guidelines
Add a section to CLAUDE.md or create a CONTRIBUTING.md with guidelines:
- When to add validation tags
- How to validate structs (call validator in constructors)
- Examples of common validation patterns
- Exception cases (e.g., internal-only structs, value types where zero-value is valid)
3. Potential Linting/Static Analysis
Consider adding a linter rule or custom tool to:
- Detect public structs without validation tags
- Verify validation is called in constructors
- Flag potential validation issues in code review
Acceptance Criteria
Examples of Structs to Audit
bootstrap.BootstrapEntry
- Network layer message types
- Identity and addressing types
- Configuration structs
- Any public API types that could be constructed by users
References
Priority
Cosmetic / Low Priority - This is a code quality improvement that enhances safety but doesn't block current functionality. Can be addressed incrementally.
Problem
According to
CLAUDE.md, the project usesgithub.com/go-playground/validator/v10for struct validation. However, several public structs currently lack validation tags, which can lead to runtime panics when invalid instances are created.Current Issues
BootstrapEntry struct (
bootstrap/bootstrap.go:23-26) lacks validation tags:Users can create invalid
BootstrapEntryinstances with nil lookup tables, leading to potential panics at runtime.Missing validation enforcement - No systematic way to ensure new structs include appropriate validation tags
Impact
Proposed Solution
1. Add Validation Tags to Existing Structs
Identify and add validation tags to all public structs that should be validated:
Note: If
model.Identityandcore.MutableLookupTableare value types (not pointers), document why validation isn't needed or if zero-value is acceptable.2. Create Validation Guidelines
Add a section to
CLAUDE.mdor create aCONTRIBUTING.mdwith guidelines:3. Potential Linting/Static Analysis
Consider adding a linter rule or custom tool to:
Acceptance Criteria
BootstrapEntry)Examples of Structs to Audit
bootstrap.BootstrapEntryReferences
github.com/go-playground/validator/v10CLAUDE.mdas a project dependencyPriority
Cosmetic / Low Priority - This is a code quality improvement that enhances safety but doesn't block current functionality. Can be addressed incrementally.