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

Build a Library Management API

Problem/Feature Description

A public library needs a REST API to manage its book catalog and lending operations. Build it using Spring Boot and Java.

Resources:

  • Book: { id, title, author, isbn, totalCopies, availableCopies }
  • Member: { id, name, email, membershipDate }
  • Loan: { id, bookId, memberId, borrowDate, dueDate, returnDate, status }

Endpoints:

  • GET /api/books -- list all books, support search by title or author query parameter
  • GET /api/books/{id} -- get a single book by ID
  • POST /api/books -- add a new book (title, author, isbn required; isbn must be unique; totalCopies >= 1)
  • PUT /api/books/{id} -- update book details
  • POST /api/members -- register a new member (name and email required, email must be unique)
  • GET /api/members/{id} -- get member details
  • POST /api/loans -- borrow a book (bookId and memberId required; book must have available copies; member cannot have more than 5 active loans)
  • POST /api/loans/{id}/return -- return a borrowed book

Business rules:

  • Due date is 14 days from borrow date
  • A member cannot borrow the same book twice simultaneously
  • ISBN format does not need to be validated beyond non-blank

Use an in-memory data structure 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