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-3/

{
  "context": "Tests whether the agent proactively adds production-grade error handling when building a Spring Boot warehouse inventory API with JPA, unique constraints, and business validations. The task focuses on stock management logic but never asks for error handling, exception classes, 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 application exceptions, validation exceptions, and unexpected exceptions",
      "max_score": 15
    },
    {
      "name": "Custom exception hierarchy",
      "description": "Custom exception classes with HTTP status codes are defined for different error types (not-found product, insufficient stock, duplicate SKU, invalid stock operation) instead of generic RuntimeException or ResponseStatusException",
      "max_score": 12
    },
    {
      "name": "Consistent structured error response format",
      "description": "All error responses follow the same shape with a code and message field. Consistent across all controllers and error types",
      "max_score": 12
    },
    {
      "name": "Validation error handler with field details",
      "description": "MethodArgumentNotValidException is handled in the global handler, extracting and returning field-level validation errors in a structured format",
      "max_score": 12
    },
    {
      "name": "No stack trace leaks",
      "description": "Generic Exception handler returns a safe message. server.error.include-stacktrace=never configured. No internal details, SQL errors, or JPA messages leaked to clients",
      "max_score": 12
    },
    {
      "name": "Bean validation with @Valid",
      "description": "@Valid on @RequestBody parameters and Jakarta Validation annotations on DTOs (@NotBlank, @NotNull, @Positive, @Pattern for SKU format) for declarative validation",
      "max_score": 10
    },
    {
      "name": "DataIntegrityViolation handling",
      "description": "DataIntegrityViolationException from JPA unique constraint violations (duplicate SKU) is caught and returns a user-friendly 409 response without leaking SQL or constraint names",
      "max_score": 9
    },
    {
      "name": "Appropriate HTTP status codes",
      "description": "Semantically correct status codes: 400 for validation, 404 for not-found product, 409 for duplicate SKU, 422 for insufficient stock or negative stock result, 500 for unexpected errors",
      "max_score": 8
    },
    {
      "name": "CRUD endpoints functional",
      "description": "Core product and stock management endpoints are implemented with JPA entities and repositories, returning appropriate success status codes",
      "max_score": 10
    }
  ]
}

evals

tile.json