Debug Failing Tests in a Django Movie Search and Filter API

Read the full interview experience this question came from →

Quick Overview

Debug an existing Django movie catalog API whose automated tests fail, covering URL routing, query parameter handling, queryset filters on genre, director, writer, rating and year, result ordering with tie-breakers, and HTTP 500 errors. It tests a systematic, layer-by-layer debugging process under a time limit.

Debug Failing Tests in a Django Movie Search and Filter API

Company: Amazon

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: Online Assessment

You are given an existing Django project that serves a movie catalog API, together with a suite of automated tests, several of which fail. You have 60 minutes to make the failing tests pass by fixing the application code. You are not asked to build anything in Django from scratch. The tests exercise endpoints that accept an optional free-text search query, filters on fields such as genre, director, writer, rating and year, and a required order for the returned results. Treat the tests as the specification. The work is to find and fix the defects in routing, request handling, querying and response building that make them fail. ### Constraints and Clarifications - The models, URL configuration, views and tests already exist. - Fix application code. Assume the tests are correct unless one clearly contradicts the others. - You can run the whole suite and individual tests locally. ### Clarifying Questions - Are the tests the full specification, or is there also a written description of the endpoints? - May tests be modified, or only application code? - When a filter value is invalid (for example, a non-numeric year), should the endpoint return an error status or ignore the filter? - Are text filters such as genre exact or case-insensitive matches, and are rating and year bounds inclusive? Where would you look in the tests to find out? ### Part 1 — Triage the failures You run the suite and see failures spread over several endpoints: some are assertion failures and some are HTTP 500 responses. Before editing anything, how do you organize the failures, and in what order do you trace a single failing test through the code? ```hint Follow the request Trace a failing request the way Django handles it, from the URL it hits to the response it returns. Ask at which layer the behavior first diverges from what the test expects. ``` #### What This Part Should Cover - Grouping failures by endpoint and shared root cause before fixing anything - A layer-by-layer trace order from the test to the response - Which failures to fix first, and why ### Part 2 — Wrong or missing results For each symptom below, explain what you would check and what the likely defects are: 1. A request with filters but no search query returns no results or an error, while the same filters with a query work. 2. Filtering by genre, director or writer returns the wrong movies, or returns some movies more than once. 3. Movies whose rating or year sits exactly on a filter boundary are missing or wrongly included. 4. A filter seems to be ignored entirely. ```hint Parameters and querysets Read how the view pulls each parameter out of the request and how each filter is added to the queryset. Then compare every lookup path with the actual model fields and relations. ``` #### What This Part Should Cover - Parameter extraction and type conversion - Composing optional filters on a queryset - Lookup paths through relations, and duplicate rows caused by joins - Boundary semantics for numeric filters ### Part 3 — Ordering and server errors The number of results is now right, but some tests still fail on the order of the results, and one endpoint returns HTTP 500. How do you find and fix each problem? ```hint Determinism and tracebacks Ask what decides the order of two movies that tie on the primary sort key. For the 500, start from the exception at the end of the traceback and walk up to the first frame in the project's own code. ``` #### What This Part Should Cover - An explicit sort with tie-breakers that match the tests - Reading a traceback to find the failing layer - Turning invalid input into a client error instead of a crash ### What a Strong Answer Covers - A systematic, layered debugging process instead of trial-and-error edits - Correct Django mechanics: URL routing, `request.GET`, queryset composition, field lookups and `order_by` - Fixing each root cause once, rather than patching tests one by one - Rerunning the full suite after each fix to catch regressions - Time management across the 60-minute window ### Follow-up Questions - One failing test seems to contradict another. How do you decide which behavior is intended? - How would you check that your fix does not make the endpoint issue extra database queries per returned movie? - What tests would you add so that these bugs cannot come back?

Overview: Debug an existing Django movie catalog API whose automated tests fail, covering URL routing, query parameter handling, queryset filters on genre, director, writer, rating and year, result ordering with tie-breakers, and HTTP 500 errors. It tests a systematic, layer-by-layer debugging process under a time limit.

Read the full Amazon Software Engineer interview experience this question came from

Community answers

Answer by aliza.systems

Part 1: I will start by tracing the endpoint for the 500 failures. I start from the first point of entry and trace whether there are issues related to how the data is being handled. If the database is being updated, is it with the correct model? For the assertion errors, that means the code is not behaving the way it should. I will manually test that data and find the point in the code where some business logic is mishandled. I will fix 500 errors first because they may introduce new assertion errors, and then I will fix the assertions altogether. Part 2: The way filters are being passed to create the query might be an issue maybe an extra ',' or incorrect data type being passed. Syntax issue Multiple query calls, not taking the correct inputs or after selection of category, its not rightly passed or not passed at all. Or a query join issue. For the number filter, equal to condition is missing. The filter value is not being passed to the database query connector (ORM)
Amazon logo
Amazon
Sep 9, 2026
hardSoftware EngineerOnline AssessmentSoftware Engineering Fundamentals
48
0

You are given an existing Django project that serves a movie catalog API, together with a suite of automated tests, several of which fail. You have 60 minutes to make the failing tests pass by fixing the application code. You are not asked to build anything in Django from scratch.

The tests exercise endpoints that accept an optional free-text search query, filters on fields such as genre, director, writer, rating and year, and a required order for the returned results. Treat the tests as the specification. The work is to find and fix the defects in routing, request handling, querying and response building that make them fail.

Constraints and Clarifications

  • The models, URL configuration, views and tests already exist.
  • Fix application code. Assume the tests are correct unless one clearly contradicts the others.
  • You can run the whole suite and individual tests locally.

Clarifying Questions Guidance

  • Are the tests the full specification, or is there also a written description of the endpoints?
  • May tests be modified, or only application code?
  • When a filter value is invalid (for example, a non-numeric year), should the endpoint return an error status or ignore the filter?
  • Are text filters such as genre exact or case-insensitive matches, and are rating and year bounds inclusive? Where would you look in the tests to find out?

Part 1 — Triage the failures

You run the suite and see failures spread over several endpoints: some are assertion failures and some are HTTP 500 responses. Before editing anything, how do you organize the failures, and in what order do you trace a single failing test through the code?

What This Part Should Cover Guidance

  • Grouping failures by endpoint and shared root cause before fixing anything
  • A layer-by-layer trace order from the test to the response
  • Which failures to fix first, and why

Part 2 — Wrong or missing results

For each symptom below, explain what you would check and what the likely defects are:

  1. A request with filters but no search query returns no results or an error, while the same filters with a query work.
  2. Filtering by genre, director or writer returns the wrong movies, or returns some movies more than once.
  3. Movies whose rating or year sits exactly on a filter boundary are missing or wrongly included.
  4. A filter seems to be ignored entirely.

What This Part Should Cover Guidance

  • Parameter extraction and type conversion
  • Composing optional filters on a queryset
  • Lookup paths through relations, and duplicate rows caused by joins
  • Boundary semantics for numeric filters

Part 3 — Ordering and server errors

The number of results is now right, but some tests still fail on the order of the results, and one endpoint returns HTTP 500. How do you find and fix each problem?

What This Part Should Cover Guidance

  • An explicit sort with tie-breakers that match the tests
  • Reading a traceback to find the failing layer
  • Turning invalid input into a client error instead of a crash

What a Strong Answer Covers Guidance

  • A systematic, layered debugging process instead of trial-and-error edits
  • Correct Django mechanics: URL routing, request.GET , queryset composition, field lookups and order_by
  • Fixing each root cause once, rather than patching tests one by one
  • Rerunning the full suite after each fix to catch regressions
  • Time management across the 60-minute window

Follow-up Questions Guidance

  • One failing test seems to contradict another. How do you decide which behavior is intended?
  • How would you check that your fix does not make the endpoint issue extra database queries per returned movie?
  • What tests would you add so that these bugs cannot come back?