Skip to content

sentry api: empty-body 404 prints nothing on stdout or stderr #1423

Description

@sergical

A request to a path that matches no route exits 60 and prints zero bytes on both stdout and stderr. There is no way to tell a routing miss from a successful empty response.

Repro

$ sentry api /api/0/definitely-not-real/ ; echo "exit=$?"
exit=60
$ sentry api /api/0/issues/7670740039/committers/ 2>&1 | wc -c
       0

Compare a 404 that does carry a JSON body — this one is reported correctly:

$ sentry api /api/0/issues/99999999999/
{
  "detail": "The requested resource does not exist"
}

Cause

Sentry returns two kinds of 404. When a route matches but the object is missing, DRF returns {"detail": ...} and the CLI prints it. When no route matches at all, Django returns an empty body, and the CLI prints nothing — it appears to render the response body without falling back to the status code when that body is empty.

Expected

Any non-2xx should print something on stderr, at minimum the status code and the requested URL. e.g.

error: 404 Not Found — GET /api/0/issues/7670740039/committers/

Why it matters

sentry api is the documented escape hatch for endpoints without a dedicated command, so it is used with paths that are guessed. A silent failure reads as "the endpoint exists and returned nothing", which is the opposite of the truth. I lost real time to this while looking for the committers endpoint — the issue-level path 404s silently, and the actual route is event-level (/projects/{org}/{proj}/events/{event_id}/committers/).

Version

0.43.0-dev.1786559401, behaviour confirmed against origin/main @ 47ad7e4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions