AI Engineer Problems › API Design and Debugging

Bug Hunt: Issue Tracker API

Medium · Code Comprehension · API Design and Debugging · Asked at Amazon

Bug Hunt: Issue Tracker API

You are reviewing a Django REST Framework codebase for an Issue Tracker API built by a junior developer. The API lets authenticated users create, list, update, and delete issues, and add comments to them.

The test suite has 6 tests, and they're all failing. Your job is to find and fix the 6 bugs hidden in views.py so that every test passes.

You should only edit views.py. The models, serializers, URL config, and tests are all correct.


API Reference

Issues

Method Endpoint Description
GET /api/issues/ List all issues. Supports ?status= query param filter.
POST /api/issues/ Create a new issue. Returns 201 Created.
GET /api/issues/<id>/ Retrieve a single issue with its comments. Returns 404 if not found.
PUT /api/issues/<id>/ Update an issue (partial). Persists changes and returns updated data.
DELETE /api/issues/<id>/ Delete an issue. Only the creator may delete. Returns 204 on success, 403 if not the creator.

Comments

Method Endpoint Description
GET /api/issues/<id>/comments/ List all comments on an issue.
POST /api/issues/<id>/comments/ Add a comment. The text field is required (non-empty). Returns 400 if missing/empty.

Models

Issue
  - id (auto)
  - title (string, required)
  - description (string, optional)
  - status (string: "open" | "closed" | "in_progress", default "open")
  - priority (string: "low" | "medium" | "high", default "medium")
  - creator (FK → User)
  - created_at, updated_at (auto timestamps)

Comment
  - id (auto)
  - text (string, required)
  - author (FK → User)
  - issue (FK → Issue)
  - created_at (auto timestamp)

Serializers

  • IssueListSerializer — used for list and create (fields: id, title, status, priority, creator, created_at)
  • IssueDetailSerializer — used for detail/update (all fields + nested comments)
  • CommentSerializer — used for comments (fields: id, text, author, created_at)

What to look for

Each bug is a small, realistic mistake — the kind that slips through a quick code review. Think about:

  • HTTP status codes — are the right ones being returned?
  • Query parameter names — do they match what the client sends?
  • Data persistence — is data actually being saved before it's returned?
  • Authorization — who should be allowed to do what?
  • Input validation — are required fields being checked?

Solve it in the browser on GenAIDojo