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

task.mdevals/scenario-2/

Build an Event Booking API

Problem/Feature Description

A community center needs a REST API to manage event scheduling and ticket booking. Build it using Spring Boot and Java.

Resources:

  • Event: { id, title, description, date, location, capacity, ticketPrice, status }
  • Booking: { id, eventId, attendeeName, attendeeEmail, numberOfTickets, totalPrice, bookingDate, confirmationCode }

Endpoints:

  • GET /api/events -- list events, support filtering by date range (from/to query params) and status
  • GET /api/events/{id} -- get event details including remaining capacity
  • POST /api/events -- create an event (title required, date must be in the future, capacity >= 1, ticketPrice >= 0)
  • PUT /api/events/{id} -- update event details (cannot change capacity below current bookings)
  • DELETE /api/events/{id} -- cancel an event (only if status is "draft"; refund logic out of scope)
  • POST /api/events/{id}/bookings -- book tickets for an event:
    • attendeeName and attendeeEmail required
    • numberOfTickets must be between 1 and 10
    • event must be in "published" status
    • event must have sufficient remaining capacity
    • generate a unique confirmation code
    • calculate total price
  • GET /api/bookings/{confirmationCode} -- look up a booking by confirmation code
  • DELETE /api/bookings/{confirmationCode} -- cancel a booking (release capacity back to event)

Business rules:

  • Event dates must be in the future when created
  • Same email cannot book the same event more than once
  • Event status transitions: draft -> published -> completed (or draft -> cancelled)
  • Cannot book tickets for a completed or cancelled event

Use in-memory storage or H2 embedded database.

Output Specification

Produce a complete Spring Boot project:

  • src/main/java/com/example/ -- controller, service, model, and repository packages
  • pom.xml or build.gradle -- with dependencies
  • src/main/resources/application.properties -- configuration

You may create additional files as needed for a well-structured codebase.

evals

tile.json