Skip to main content

A Python package for tracking Flask errors via GitHub Issues.

Project description

flask-github-issues

flask-github-issues is an extension for Flask that makes it easy to send unhandled errors directly from your application to GitHub Iusses.

An Example:

pip install flask_github_issues

extensions.py

from flask_github_issues import ErrorTracking

gitub_error_tracking = ErrorTracking()

init.py

from flask import Flask, request, session
import traceback

from .extensions import gitub_error_tracking

def create_app(config_env=os.getenv("ENV"), register_blueprints=True):
    app = Flask(__name__)

    gitub_error_tracking.init_app(app)


@app.errorhandler(Exception)
    def internal_server_error(e):
        if request.path.startswith("/static/"):
            # Return a simple 500 response without rendering a template
            return "", 500
        else:
            
            error_msg = traceback.format_exc()
            user_email = session.get("email", "unknown")
            github_error_tracking.track_error(error_message=str(error_msg),
                details=[
                    {"User Email": user_email},
                    {"URL": request.url},
                    {"Tenant": "TEST"},
                ],
            )
            return render_template("500.html"), 500

config.py:

class Config:
    GH_TOKEN = os.getenv("GH_TOKEN")
    GH_REPO = os.getenv("GH_REPO")
    GH_ASSIGNEES = ["ghawes85"]
    GH_LABELS = ["bug"]
    GH_TYPES = "bug" # Types is being released in the GitHub API. Currently if it is rolled out for you or your org, then can add one type
  • Repo is in the form org/repo_name or user/repo_name
  • Token is a Github fine-grained personal access token
  • Assignees is a list of of users you want the ticket to be assigned to
  • Labels is a list of labels you want assigned to your ticket

As an example and using the follow route:

@app.route("/error")
    def error():
        raise ValueError("This is a test Value ERROR")

The following issue is created in GitHub image

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

flask_github_issues-0.1.5.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

flask_github_issues-0.1.5-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file flask_github_issues-0.1.5.tar.gz.

File metadata

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

File hashes

Hashes for flask_github_issues-0.1.5.tar.gz
Algorithm Hash digest
SHA256 3b4bfe57420575a35fcfbb54399ca3c0e0043fddac2b018b63a291ef151a3c4a
MD5 73ff48638340f74b3d9692e066b325ad
BLAKE2b-256 3344ae229521219296d9bdd002b03cfa9e9d0f689d0416258ea83ac734f6cc09

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_github_issues-0.1.5.tar.gz:

Publisher: pypi_publish.yaml on Pontem-Innovations/flask-github-issues

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

File details

Details for the file flask_github_issues-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_github_issues-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ae71eb1956607d2f57345b07ffd48a1b5addf97712f0a1c4ee06960e594657cf
MD5 08967004b0f3a22523d027c21f68f73a
BLAKE2b-256 3a46d1b0aee18105d7eb07665b444721702b55672bb0ca18f61744ba3a99e166

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_github_issues-0.1.5-py3-none-any.whl:

Publisher: pypi_publish.yaml on Pontem-Innovations/flask-github-issues

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