Skip to content

Hide a 500's exception text by default, with an error id (closes #35) - #52

Open
thorwhalen wants to merge 1 commit into
masterfrom
b8/opaque-500-default
Open

thorwhalen wants to merge 1 commit into
masterfrom
b8/opaque-500-default

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

Approve = merge. This changes what clients see on a 500, so it is opened for a maintainer decision and not merged (option 1 of #35).

What. server_error_message(error) is the one place a 500's text is decided, used by the Bottle, Flask and aiohttp handlers. By default the client gets Internal server error (error id <12 hex>) and the exception is logged (logger.error, with traceback) under that id. PY2HTTP_EXPOSE_ERRORS=1 sends str(error) as before (development). OPAQUE_ERRORS is still honoured and wins over expose. 4xx answers are unchanged.

Who is affected. A client or test that reads the exception text from a 500 body sees the generic message unless the server sets PY2HTTP_EXPOSE_ERRORS. Dependents were not run (priv test-dependents py2http belongs before merge).

Options. (1) this PR; (2) keep sending the text and document OPAQUE_ERRORS as the production setting.
Default: (1), matching i2mint/qh#18 and the aiohttp handler, which already hid the text.
Reverse. Revert, or set PY2HTTP_EXPOSE_ERRORS=1 on a service that needs the old behaviour.

Tests: 317 passed (including doctests); new tests for the default, expose, and OPAQUE-wins cases.

PY2HTTP_EXPOSE_ERRORS=1 sends the text again; OPAQUE_ERRORS still forces the
generic message. Bottle, Flask and aiohttp handlers share server_error_message.
@thorwhalen thorwhalen added the needs-owner A recommendation awaiting the maintainer's decision: Approve = merge label Nov 23, 2026

This branch has not been deployed

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

Labels

needs-owner A recommendation awaiting the maintainer's decision: Approve = merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant