Debug Issue and Subtask Creation in a Mongoose-Backed Issue Tracker

Quick Overview

A debugging exercise in a Jira-style issue tracker backed by MongoDB and Mongoose, where creating issues and subtasks fails. It tests how a candidate traces a failing request to schema validation, casting and parent references, and how they write populate and count queries across teams.

Debug Issue and Subtask Creation in a Mongoose-Backed Issue Tracker

Company: Amazon

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: Technical Screen

You join an unfamiliar full-stack issue tracker modeled on Jira. The back end runs on Node.js and stores data in MongoDB through Mongoose. An issue (a task) belongs to a team, has an assignee and a creator, and sits in a status column such as the backlog. A task can have sub-issues (subtasks). Two features are broken: 1. Creating an issue fails. It fails from the backlog and from every other status column. 2. Creating a sub-issue under an existing task also fails. Both defects are in the back end, around data validation, how documents are stored and how Mongoose operations are used. You work inside the repository with an AI coding assistant available, and the repository's test cases check your fixes. Find the cause of each failure, fix it, and explain the fix. ### Constraints and Clarifications - An issue references its team, its assignee and its creator by `ObjectId`, each with a `ref` to the matching model. - A sub-issue must store a correct reference to its parent issue. - Some endpoints expand references with `populate()` and select only some fields, for example a team's `name` and `description`. - The app counts issues for a single team and for all teams. ### Clarifying Questions - When creation fails, what does the API return: a validation error, a cast error, a 500, or a success response with nothing stored? - Do the field names and status values the front end sends match the schema? - Should a subtask take its team and status from its parent, or does the client send them? - Is the parent link stored on the child, on the parent as an array of children, or on both? ### Part 1: Fix issue creation Explain how you would locate the failure, starting from a single create request, and what you would inspect in the schema and the create handler. Describe the defects that would make creation fail in every column, how you would confirm which one it is, and how you would fix it. ```hint Start from the exact error Reproduce one create request and read the error Mongoose reports before reading code. A failure in every column points at something every create request shares. ``` #### What This Part Should Cover - A reproduce-first path from the HTTP request to the stored document. - Mongoose behavior for required fields, enums, casting to `ObjectId` and unknown fields. - A root-cause fix and a test that fails before it and passes after. ### Part 2: Fix subtask creation Creating a sub-issue under a task fails too. Model the parent-child relationship and explain what the create path must do so that a subtask is stored with a correct parent reference and the parent can list its subtasks. ```hint Follow the parent id Trace how the parent's id travels from the URL or the request body into the new document, and check whether the schema keeps that field at all. ``` #### What This Part Should Cover - Where the parent reference lives and how it is validated. - Keeping parent and child consistent if both store the link. - Edge cases such as a missing parent, a parent on another team and nested subtasks. ### Part 3: Queries over issues and teams Write the Mongoose calls to (a) list a team's issues with the team expanded to only its `name` and `description`, (b) count the issues of one team and (c) count the issues of every team in one query. ```hint One team versus every team Counting for one known team and grouping counts across all teams are different operations in MongoDB. ``` #### What This Part Should Cover - `populate()` with field selection. - A filtered count compared with an aggregation that groups by team. - How ids are typed in filters and which indexes these queries need. ### What a Strong Answer Covers - A disciplined way to debug an unfamiliar repository, using the AI assistant to read code faster while checking its claims. - Accurate Mongoose mechanics: validation, casting, strict mode, refs and population. - Fixes that address the root cause without loosening validation, backed by tests. - A clear explanation of each cause. ### Follow-up Questions - The front end sends a team's name where the API expects its id. Where should that be caught, and what should the API return? - How would you stop a subtask from pointing at itself or at a task on another team? - Counting issues for every team is slow on a large collection. What would you change? - The AI assistant proposes a fix that makes the error disappear. How do you check it before accepting it?

Overview: A debugging exercise in a Jira-style issue tracker backed by MongoDB and Mongoose, where creating issues and subtasks fails. It tests how a candidate traces a failing request to schema validation, casting and parent references, and how they write populate and count queries across teams.

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

Amazon logo
Amazon
Nov 27, 2026
hardSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

You join an unfamiliar full-stack issue tracker modeled on Jira. The back end runs on Node.js and stores data in MongoDB through Mongoose. An issue (a task) belongs to a team, has an assignee and a creator, and sits in a status column such as the backlog. A task can have sub-issues (subtasks). Two features are broken:

  1. Creating an issue fails. It fails from the backlog and from every other status column.
  2. Creating a sub-issue under an existing task also fails.

Both defects are in the back end, around data validation, how documents are stored and how Mongoose operations are used. You work inside the repository with an AI coding assistant available, and the repository's test cases check your fixes. Find the cause of each failure, fix it, and explain the fix.

Constraints and Clarifications

  • An issue references its team, its assignee and its creator by ObjectId , each with a ref to the matching model.
  • A sub-issue must store a correct reference to its parent issue.
  • Some endpoints expand references with populate() and select only some fields, for example a team's name and description .
  • The app counts issues for a single team and for all teams.

Clarifying Questions Guidance

  • When creation fails, what does the API return: a validation error, a cast error, a 500, or a success response with nothing stored?
  • Do the field names and status values the front end sends match the schema?
  • Should a subtask take its team and status from its parent, or does the client send them?
  • Is the parent link stored on the child, on the parent as an array of children, or on both?

Part 1: Fix issue creation

Explain how you would locate the failure, starting from a single create request, and what you would inspect in the schema and the create handler. Describe the defects that would make creation fail in every column, how you would confirm which one it is, and how you would fix it.

What This Part Should Cover Guidance

  • A reproduce-first path from the HTTP request to the stored document.
  • Mongoose behavior for required fields, enums, casting to ObjectId and unknown fields.
  • A root-cause fix and a test that fails before it and passes after.

Part 2: Fix subtask creation

Creating a sub-issue under a task fails too. Model the parent-child relationship and explain what the create path must do so that a subtask is stored with a correct parent reference and the parent can list its subtasks.

What This Part Should Cover Guidance

  • Where the parent reference lives and how it is validated.
  • Keeping parent and child consistent if both store the link.
  • Edge cases such as a missing parent, a parent on another team and nested subtasks.

Part 3: Queries over issues and teams

Write the Mongoose calls to (a) list a team's issues with the team expanded to only its name and description, (b) count the issues of one team and (c) count the issues of every team in one query.

What This Part Should Cover Guidance

  • populate() with field selection.
  • A filtered count compared with an aggregation that groups by team.
  • How ids are typed in filters and which indexes these queries need.

What a Strong Answer Covers Guidance

  • A disciplined way to debug an unfamiliar repository, using the AI assistant to read code faster while checking its claims.
  • Accurate Mongoose mechanics: validation, casting, strict mode, refs and population.
  • Fixes that address the root cause without loosening validation, backed by tests.
  • A clear explanation of each cause.

Follow-up Questions Guidance

  • The front end sends a team's name where the API expects its id. Where should that be caught, and what should the API return?
  • How would you stop a subtask from pointing at itself or at a task on another team?
  • Counting issues for every team is slow on a large collection. What would you change?
  • The AI assistant proposes a fix that makes the error disappear. How do you check it before accepting it?