Skip to main content

FaultSnap

1. What is FaultSnap?

FaultSnap is a black-box recorder for Python applications. When your program crashes, FaultSnap captures the execution context, stores it in a portable .faultsnap archive, and allows another developer to inspect the crash without reproducing it.

2. Why FaultSnap Exists

When an exception occurs, Python provides a standard traceback. However, tracebacks only give you the file and line number. They don't tell you the state of variables at the time of the crash.

user = None
print(user.name) # AttributeError: 'NoneType' object has no attribute 'name'

Why is user None? What were the variables leading up to this? With FaultSnap, you can inspect every local variable, frame by frame, exactly as it was when the crash occurred.

3. Installation

pip install faultsnap

To enable offline HTML report generation:

pip install faultsnap[html]

4. Quick Start

import faultsnap

faultsnap.install()

1 / 0

Output:

[FaultSnap] Crash captured. Saved to FaultSnaps/ZeroDivisionError/2026-06-13/1eaee423/crash_232934_1eaee423.faultsnap

5. How FaultSnap Works

  1. Capture: Intercepts unhandled exceptions globally or via framework middleware.
  2. Serialize: Traverses the execution stack safely, truncating large structures and handling circular references to prevent cascading failures.
  3. Mask: Redacts sensitive data (like passwords, keys, and tokens) matching predefined or custom regex patterns.
  4. Fingerprint: Computes a unique SHA-256 hash based on the execution path to group identical crashes.
  5. Package: Generates a .faultsnap ZIP archive with manifest metadata and a standalone HTML report.
  6. Analyze: Use the CLI to search, inspect, and visualize crashes from the repository.

6. Crash Repository Structure

FaultSnap organizes all crashes in a central FaultSnaps/ directory to prevent cluttering your project root. The repository maintains an index.json to allow fast searching and a latest/ folder pointing to the most recent crash.

FaultSnaps/
├── index.json
├── latest/
│   ├── latest.faultsnap
│   └── latest.html
└── ZeroDivisionError/
    └── 2026-06-13/
        └── 1eaee423/
            ├── crash_232934.faultsnap
            ├── crash_232934.html
            └── metadata.json

7. Complete CLI Reference

Manage and analyze your crashes directly from the terminal.

faultsnap list

Purpose: Shows all stored crashes in a tabular view. Syntax: faultsnap list Example Output:

Timestamp                Exception            Fingerprint
----------------------------------------------------------------
2026-06-13 23:29:34      ZeroDivisionError    1eaee423
2026-06-13 23:31:15      AttributeError       3abf9121

faultsnap latest

Purpose: Inspect the most recent crash. Syntax: faultsnap latest Example: Immediately displays the metadata and exception string for the crash in FaultSnaps/latest/.

Purpose: Search the crash index by exception type or fingerprint. Syntax: faultsnap search <term> Example: faultsnap search ZeroDivisionError or faultsnap search 1eaee423

faultsnap stats

Purpose: Display repository statistics. Syntax: faultsnap stats Example Output:

Total Crashes: 154
Unique Fingerprints: 23
Most Common Error: AttributeError
Oldest Crash: 2026-05-01
Newest Crash: 2026-06-13

faultsnap clean

Purpose: Remove expired reports based on the retention policy configured via faultsnap.configure(max_days_to_keep=30). Syntax: faultsnap clean

faultsnap inspect

Purpose: View high-level metadata and the raw traceback for a specific capsule. Syntax: faultsnap inspect <file> Example: faultsnap inspect FaultSnaps/latest/latest.faultsnap

faultsnap stack

Purpose: Render an interactive tree view of the call stack. Syntax: faultsnap stack <file>

faultsnap vars

Purpose: View local variables for every execution frame. Syntax: faultsnap vars <file>

faultsnap env

Purpose: View captured environment variables safely. Syntax: faultsnap env <file>

faultsnap fingerprint

Purpose: Print the unique hash of the crash. Syntax: faultsnap fingerprint <file>

faultsnap diff

Purpose: Compare metadata between two different crash files. Syntax: faultsnap diff <file1> <file2>

faultsnap html

Purpose: Generate a standalone HTML dashboard for a specific capsule. Syntax: faultsnap html <file>

8. HTML Reports

The HTML report provides an interactive diagnostic dashboard that operates completely offline. It features:

  • Search & Variable Filtering: Quickly find specific variables across deep call stacks.
  • Stack Exploration: Expand/collapse frames to view line-by-line context and local state.
  • Execution Graph: A visual flow of the exception path via a bundled Mermaid.js graph.

9. Framework Integrations

FaultSnap provides explicit integration handlers for major frameworks.

AsyncIO

import asyncio
from faultsnap.integrations.asyncio import install

async def main():
    install()
    # Async execution

Multiprocessing

from faultsnap.integrations.multiprocessing import install
install()

Flask

from flask import Flask
from faultsnap.integrations.flask import install

app = Flask(__name__)
install(app)

FastAPI

from fastapi import FastAPI
from faultsnap.integrations.fastapi import install

app = FastAPI()
install(app)

Django Add to MIDDLEWARE in settings.py:

MIDDLEWARE = [
    'faultsnap.integrations.django.FaultSnapMiddleware',
]

Streamlit

from faultsnap.integrations.streamlit import install
install()

Pytest In conftest.py:

pytest_plugins = ["faultsnap.integrations.pytest_plugin"]

10. Security Features

  • Secret Masking: Automatically redacts values for keys containing terms like password, secret, token, key, and auth.
  • Safe Environment Capture: Captures only benign OS variables (PATH, OS, TERM) by default to prevent accidental credential leaks.
  • Offline Operation: FaultSnap operates strictly offline. It never transmits data externally and HTML reports embed all necessary dependencies.
  • HTML Escaping: Strict Jinja2 autoescaping prevents XSS vulnerabilities in generated reports.

11. Performance

  • Depth Limits: Traversal stops at a safe recursion depth (max_depth=5).
  • Truncation: Lists and strings are truncated to prevent infinite evaluation and memory exhaustion (max_items=50).
  • Memory Protection: A global persistent counter enforces a hard limit on the total number of objects processed (max_total_items=10000).

12. Architecture Overview

  • core.py: Injects hooks into Python runtimes and extracts context from f_locals.
  • serializer.py: Safely evaluates and truncates arbitrary Python objects into JSON-friendly formats.
  • mask.py: Scans keys and redacts sensitive data using regex.
  • fingerprint.py: Generates a unified SHA-256 hash representing the crash path.
  • capsule.py: Compresses the payload into a .faultsnap ZIP archive.
  • storage.py: Organizes artifacts into the hierarchical FaultSnaps/ repository, updates indexes, and handles retention.
  • html.py: Combines crash metadata with Jinja2 templates for interactive offline reports.
  • cli.py: Powers the interactive terminal inspector.

13. FAQ

Q: Why is my variable truncated? A: FaultSnap imposes strict bounds (max_items, max_string_len) to ensure the crash capturer never causes an Out-Of-Memory error itself. You can increase these via faultsnap.configure().

Q: Why are passwords masked? A: To prevent accidental exfiltration or logging of secrets in developer crash dumps.

Q: How do I open a .faultsnap file? A: Use the FaultSnap CLI (faultsnap inspect <file>) or generate an HTML report (faultsnap html <file>).

Q: Can I share crash files with teammates? A: Yes. The .faultsnap and .html files are fully standalone. You can share them directly with other developers to analyze the crash offline.

Q: Does FaultSnap send data anywhere? A: No. It operates entirely offline.

14. Contributing

Contributions are welcome! Please ensure you run the pytest suite before submitting pull requests.

15. License

MIT License.

Metadata

Release files for FaultSnap 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for FaultSnap 1.0.3
File Size Uploaded Provenance Actions
faultsnap-1.0.3.tar.gz 928.0 kB With provenance Details for faultsnap-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for FaultSnap 1.0.3
File Interpreter ABI Platform Actions
faultsnap-1.0.3-py3-none-any.whl Python 3 none any Details for faultsnap-1.0.3-py3-none-any.whl

Total release size: 1.9 MB

Release files / faultsnap-1.0.3.tar.gz

Download URL faultsnap-1.0.3.tar.gz
Size 928.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5c5e06173f8d3bba070f6b68c48bda0199faa9632a0fb298df10cbd5b81706a5
BLAKE2b-256 checksum
How to use checksums
5453f58b038109c134b98fe647135343b935c3b3d4e94fe486074fa4b616b67c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

Release files / faultsnap-1.0.3-py3-none-any.whl

Download URL faultsnap-1.0.3-py3-none-any.whl
Size 934.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
050c8eaac22a7ec6937626b883a5722a36ea674b731ec55f8a1cd7bcacbc7190
BLAKE2b-256 checksum
How to use checksums
2522967d0d2d7aade92ab98d36c65c3ab11b7943bf4e43c74f57332fad3241c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

Security for FaultSnap 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for faultsnap-1.0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page