Skip to main content

Automatic GitHub issue creation + PR fix on runtime errors

Project description

Splat

PyPI version Python versions License

Automatic GitHub issue creation on application crashes with optional Claude Code auto-fix.

Features

  • Zero-config crash reporting - Add two lines, get GitHub issues on errors
  • True deduplication - Checks GitHub before creating, works across restarts/instances
  • Rich context - Rolling log buffer, framework-specific request context, custom metadata
  • Auto-fix ready - One command installs a GitHub Action that uses Claude Code to fix reported bugs

Installation

pip install py-splat

With framework support:

pip install py-splat[flask]    # Flask
pip install py-splat[fastapi]  # FastAPI
pip install py-splat[cli]      # CLI tools

Quick Start

Basic Usage

from splat import Splat

splat = Splat(repo="owner/repo", token="ghp_...")

try:
    do_something()
except Exception as e:
    await splat.report(e)  # async - use in async context

With Context

try:
    process_order(user)
except Exception as e:
    await splat.report(
        e,
        context={
            "user_id": user.id,
            "endpoint": "/checkout",
        },
    )

Flask Integration

from flask import Flask
from splat.middleware.flask import SplatFlask

app = Flask(__name__)
splat = SplatFlask()
splat.init_app(app, repo="owner/repo", token="ghp_...")

FastAPI Integration

from fastapi import FastAPI
from splat.middleware.fastapi import SplatMiddleware

app = FastAPI()
app.add_middleware(SplatMiddleware, repo="owner/repo", token="ghp_...")

Configuration

Environment Variables

Variable Description Default
SPLAT_GITHUB_TOKEN GitHub API token (required)
SPLAT_GITHUB_REPO Repository (owner/repo) (required)
SPLAT_ENABLED Enable/disable reporting true
SPLAT_LOG_BUFFER_SIZE Log buffer capacity 200
SPLAT_LABELS Issue labels (comma-separated) bug,splat
SPLAT_VERCEL_SECRET Vercel webhook verification secret (optional)
SPLAT_VERCEL_WEBHOOK_PATH Vercel webhook endpoint path /splat/logs
SPLAT_VERCEL_LOG_TTL Seconds to keep Vercel logs in memory 60

pyproject.toml

[tool.splat]
repo = "owner/repo"
labels = ["bug", "splat", "auto-fix"]
log_buffer_size = 500

Precedence

Configuration is loaded with precedence: Programmatic > pyproject.toml > Environment Variables > Defaults

CLI

# Interactive setup wizard
splat init

# Install auto-fix GitHub Action
splat install-autofix

Auto-Fix with Claude Code

Splat can automatically create PRs to fix reported bugs using Claude Code:

  1. Install the auto-fix workflow:

    splat install-autofix
    
  2. Add ANTHROPIC_API_KEY to your repository secrets

  3. Add auto-fix to your labels:

    [tool.splat]
    labels = ["bug", "splat", "auto-fix"]
    

When an error is reported, Claude Code will analyze the issue, write a failing test, implement a fix, and open a PR.

Vercel Log Integration

Splat can capture Vercel runtime logs via Log Drain webhooks, providing precise logs for each failed request.

Setup

  1. Configure your app:

    Flask (webhook auto-registered):

    from flask import Flask
    from splat.middleware.flask import SplatFlask
    
    app = Flask(__name__)
    splat = SplatFlask()
    splat.init_app(app, repo="owner/repo", token="ghp_...")
    # Automatically registers /splat/logs webhook
    

    FastAPI (manual middleware wrapping to share Splat instance):

    from fastapi import FastAPI
    from splat.middleware.fastapi import SplatMiddleware
    from splat.webhooks.fastapi import create_webhook_router
    
    app = FastAPI()
    # Add webhook router first
    middleware = SplatMiddleware(app, repo="owner/repo", token="ghp_...")
    app.include_router(create_webhook_router(middleware.splat))
    # Use middleware.app or wrap app manually if needed
    
  2. Add Log Drain in Vercel:

    • Go to your project's Settings → Log Drains
    • Create a new Log Drain:
      • Delivery format: JSON
      • Endpoint: https://your-app.vercel.app/splat/logs
      • Sources: Lambda, Edge (runtime logs)
  3. (Recommended) Add verification secret:

    # Generate a secret
    export SPLAT_VERCEL_SECRET=$(openssl rand -hex 32)
    # Add to your environment variables and Vercel Log Drain config
    

How It Works

  1. Vercel pushes runtime logs to your /splat/logs endpoint
  2. Splat stores logs keyed by request ID (from x-vercel-id header)
  3. When an error occurs, middleware captures the request ID
  4. splat.report() fetches logs for that specific request
  5. GitHub issue includes the exact logs for the failed request

Logs automatically expire after 60 seconds (configurable via SPLAT_VERCEL_LOG_TTL).

Issue Format

Created issues include:

  • Error type, message, file, line, and function
  • Full traceback
  • Optional context (custom metadata you provide)
  • Recent logs (last 200 entries by default)
  • Unique signature for deduplication

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_splat-0.1.2.tar.gz (98.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_splat-0.1.2-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file py_splat-0.1.2.tar.gz.

File metadata

  • Download URL: py_splat-0.1.2.tar.gz
  • Upload date:
  • Size: 98.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_splat-0.1.2.tar.gz
Algorithm Hash digest
SHA256 196e58e825593297d0feda66374ed745bd9cd208b87263aa064f8bda1dbe17ca
MD5 0c2d3faf71cadd144a775129c3c0f149
BLAKE2b-256 b7273df89c77b56f8cf97bcc98d5a348609cac341e8957e81f374c15aadc3791

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_splat-0.1.2.tar.gz:

Publisher: publish.yml on andreaslordos/splat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_splat-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: py_splat-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 35.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_splat-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77bce9c66978cefcc2c81af4c53c67fa97fd71f9f3fd853be89d11cc812b27f1
MD5 34497024d4681f5e728057f361dddd89
BLAKE2b-256 f55263fe0216972658693574769e7b595bc6eb3e9ea683235f093e5b65448c8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_splat-0.1.2-py3-none-any.whl:

Publisher: publish.yml on andreaslordos/splat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page