Data EngineeringFDE engineering foundations

Read a stack trace and identify the failing contract

PK
Pankit Kumar
Sr. Data Scientist at Parexel (a Goldman Sachs–backed company) · 20 September 2026 · 2 min read
Technically reviewed by Ishaan Sharma
In this article (3 sections)

A stack trace is a path through calls, ending with exception type and message. The repair starts by locating the first relevant application frame and asking what assumption failed there.

Capture a minimal failure

The engineering foundations lab passes an order without total.

python
from engineering_cases import stack_trace_case

result = stack_trace_case()
assert result["exception_type"] == "KeyError"
assert result["message"] == "'total'"
assert result["contract"] == "order.total required"
assert result["failing_function"] is True

Read from the final exception upward, distinguish framework frames from application code and inspect the values entering that frame. Reproduce with the smallest payload. Then decide where the contract belongs: schema validation at ingress, a typed internal boundary or a migration.

Do not catch every exception and return “something went wrong.” Preserve causal chains, attach a correlation ID and expose a safe stable error to clients. Add the minimal failing payload as a regression fixture.

The FDE for Freshers course makes debugging evidence part of code review and interviews.

Exercise

Create a three-layer call stack with one malformed record. Identify the first bad boundary, repair it with validation and prove the regression test fails on the old code.

Continue learning

This article is part of the FDE engineering foundations sequence. Use the neighbouring tasks when you need the prerequisite or the next application.

Reference: Python `traceback` documentation.

PK
Pankit Kumar
Lead Instructor, NeuraPath Academy

Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.

This article is part of our FDE for Freshers programme — 6–7 months. Build your engineering foundations, then take AI from discovery to delivery.

Explore FDE for Freshers
Counselling is free · no obligation

Not sure which programme fits?

Tell us your background and we will map it to the right entry point — including saying so when a cheaper programme is the better fit. A counsellor replies within one working day.