Skip to content

Bottle apps send exception text to clients on 500 by default #35

Open

Description

@thorwhalen

Found by the sprint review (#34), deferred because it changes what clients see.

bottle_error_handler (the default for mk_app apps, which are always Bottle) answers a 500 with {"error": str(error)} unless the OPAQUE_ERRORS environment variable is set. Exception messages routinely carry file paths, connection strings or fragments of data, so by default a py2http service sends them to any client. The aiohttp handler already hides them; i2mint/qh did the same in i2mint/qh#18 (a generic message with an error id, the exception logged server-side under that id).

handle_error in service.py also prints every traceback to stdout, on top of the logger (#1 covers the prints).

Options:

  1. Flip the default: hide 500 text unless expose_errors=True (a config key, or the env var), and log the exception with an error id that the client gets. Clients that display error from a 500 would see the generic message instead.
  2. Keep sending the text, and document OPAQUE_ERRORS in the README as the production setting.

The aiohttp path (aiohttp_error_handler) is unreachable from mk_app today (_get_framework refuses anything but Bottle, see #7), so only Bottle matters here.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions