CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/springboot-error-handling

Error handling for Spring Boot APIs — @ControllerAdvice, structured error

84

1.76x
Quality

75%

Does it follow best practices?

Impact

99%

1.76x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-1/

{
  "context": "Tests whether the agent proactively adds production-grade error handling when building a Spring Boot HR/employee directory API with JPA relationships. The task involves entity relationships and business rules but never asks for error handling, exception handlers, or error response formatting.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Global exception handler with @RestControllerAdvice",
      "description": "A centralized exception handler class annotated with @RestControllerAdvice or @ControllerAdvice is defined, with @ExceptionHandler methods covering multiple exception types",
      "max_score": 15
    },
    {
      "name": "Custom exception hierarchy",
      "description": "Custom exception classes map business error scenarios to HTTP status codes (e.g., ResourceNotFoundException for 404, DuplicateResourceException for 409, BusinessRuleException for 422), rather than generic exceptions",
      "max_score": 12
    },
    {
      "name": "Consistent structured error response format",
      "description": "All error responses use the same object shape with a code and message field (e.g., { error: { code, message } }). Format is consistent across all endpoints and error types",
      "max_score": 12
    },
    {
      "name": "Validation error handler with field details",
      "description": "MethodArgumentNotValidException is handled in the global exception handler, returning individual field errors with field name and message in a structured list",
      "max_score": 12
    },
    {
      "name": "No stack trace leaks",
      "description": "A catch-all Exception handler returns a generic error message. server.error.include-stacktrace=never is configured or equivalent protection is in place",
      "max_score": 12
    },
    {
      "name": "Bean validation with @Valid",
      "description": "@Valid is used on @RequestBody parameters and entity/DTO classes use Jakarta Validation annotations (@NotBlank, @Email, @Positive, @Min, @Max) for declarative validation",
      "max_score": 10
    },
    {
      "name": "DataIntegrityViolation handling",
      "description": "DataIntegrityViolationException from JPA unique constraint violations (duplicate email, duplicate department name) is caught and returns a user-friendly 409 response without leaking constraint names or SQL",
      "max_score": 9
    },
    {
      "name": "Appropriate HTTP status codes",
      "description": "Correct status codes: 400 for validation, 404 for not-found employee/department, 409 for duplicate email/name, 422 for business rule violations (deleting manager, deleting non-empty department), 500 for unexpected",
      "max_score": 8
    },
    {
      "name": "CRUD endpoints functional",
      "description": "Core department and employee endpoints are implemented with JPA entities, repositories, and proper status codes for CRUD operations",
      "max_score": 10
    }
  ]
}

evals

scenario-1

criteria.json

task.md

tile.json