Error handling for Go HTTP servers — structured error responses, error wrapping,
88
81%
Does it follow best practices?
Impact
99%
1.80xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent proactively adds production error handling when building a multi-resource Go employee directory API with referential integrity constraints. The task does not mention error handling -- criteria check for structured errors, recovery middleware, proper handling of constraint violations, and validation.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Custom error type",
"description": "A custom error struct with StatusCode, Code, and Message fields is defined, implementing the error interface",
"max_score": 12
},
{
"name": "Structured JSON error responses",
"description": "All error responses use a consistent JSON shape with code and message fields. No bare http.Error calls, no plain text, no inconsistent formats.",
"max_score": 12
},
{
"name": "writeError helper",
"description": "A centralized writeError function is used by all handlers for error response formatting",
"max_score": 8
},
{
"name": "Recovery middleware",
"description": "A panic recovery middleware using defer/recover is registered that returns structured 500 JSON instead of crashing",
"max_score": 12
},
{
"name": "Graceful shutdown",
"description": "Server handles SIGTERM/SIGINT with signal.Notify and srv.Shutdown with a context timeout",
"max_score": 7
},
{
"name": "Referential integrity errors",
"description": "Deleting a department manager returns an appropriate 4xx error (e.g. 409 Conflict) with a clear message explaining why, not a 500",
"max_score": 10
},
{
"name": "Uniqueness conflicts",
"description": "Duplicate department names or employee emails return 409 Conflict with structured error messages",
"max_score": 8
},
{
"name": "Foreign key validation",
"description": "Creating an employee with a non-existent departmentId returns 400 or 422 with a message about the invalid reference, not 500",
"max_score": 8
},
{
"name": "Not-found handling",
"description": "Requests for non-existent departments or employees return 404, not 500 or 200",
"max_score": 8
},
{
"name": "No internal error leaks",
"description": "Internal errors return a generic client-safe message -- no raw error strings or internal details in responses",
"max_score": 8
},
{
"name": "All endpoints functional",
"description": "All eight endpoints are implemented with appropriate success status codes",
"max_score": 5
}
]
}