DUP-GO-3: 4 read-adapter session handlers share identical withSessionAdapter pattern #42
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman#42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Four handlers in
internal/server/handlers_sessions.goare structurally identical 11-line functions:handleSessionAgents(lines 400–412)handleSessionCommands(lines 414–426)handleSessionPermissions(lines 442–454)handleSessionQuestions(lines 456–468)Pattern
Each calls
withSessionAdapter, invokes the adapter method, nil-guards the result slice, and callswriteJSON. The only variation is the adapter method, the error message string, and the empty-slice type.Fix
Could use Go generics (
func handleSessionCollection[T any](...)) to collapse all four into a single generic handler. At minimum, the nil-guard pattern should be extracted.Effort
Medium (full generic refactor); Low (nil-guard extraction only).