map_to_code
Maps stack trace application frames to real project files, resolves path mismatches, and shows the offending source line with context so you can locate crash sites quickly.
Instructions
Map the application frames of a trace onto files in the project and show the code.
Works when the trace's paths differ from the local ones: container paths (/app/src/x.py vs ./src/x.py), Windows vs POSIX separators, webpack/vite URLs, Java package paths. Frames are matched on their trailing path components against files that actually exist under the sandbox directory. For each frame it reports FOUND / NOT FOUND / ambiguous, whether the line number exists, the offending line with +-context lines, and warns when the source line recorded in the trace differs from the file (the code changed since the crash). Paths in the trace are treated as data: '../' tricks cannot reach outside --dir and symlinks that resolve outside it are refused.
Args: text: The trace (max 5,000,000 characters). project_dir: Directory to search; must be inside --dir. Default: the first --dir. context: Lines of context before/after the offending line (0-10, default 3). max_frames: Maximum application frames to map (default 8). index: Which trace if the text contains several (0-based). redact: Remove secrets etc. from the output, including source lines (default true).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| index | No | ||
| redact | No | ||
| context | No | ||
| max_frames | No | ||
| project_dir | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |