> ## Documentation Index
> Fetch the complete documentation index at: https://docs.potpie.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Null Pointer

> Trace a null pointer exception to its origin across service and data layers.

A null pointer exception surfacing in a generic service layer shows where the crash happens, while the null value originates elsewhere. Tracing it backwards through multiple service and data layers manually leaves the true origin uncertain.

**Debug** traces the full execution path through the [context graph](https://docs.potpie.ai/concepts/context-engine.md) from the point of failure back to the source, identifies exactly where the null value enters without a guard, and returns a targeted fix.

**Issue:**

```
Users are getting null pointer errors during checkout with empty carts.
```

**Potpie traces:**

1. The checkout controller that receives the request
2. The cart service and how it handles empty state
3. The downstream order service that fails on null cart data

**Root cause citation:**

* Exact file path and line where the null value passes through without a null check
* The dependent call site that throws the exception

**Fix includes:**

* Null guard at the correct layer with the minimal change required
* Verification across all call sites for the same missing check

[**Build**](https://docs.potpie.ai/build-flow/build-a-feature.md) generates the corrected code as a reviewable **diff**.

Try it yourself on your codebase → [Debug an Issue](https://docs.potpie.ai/tutorials/trace-and-fix.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.