Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

log list/view returns 400 when user passes --query with non-numeric project slug #1319

Closed

Description

@BYK

src/lib/api/logs.ts constructs the Events (ourlogs) request by concatenating project:<slug> with the user-supplied --query:

const projectFilter = isNumericProject ? "" : `project:${projectSlug}`;
query: projectFilter ? `${projectFilter} ${userQuery}` : userQuery,

When the user passes a --query flag (or the command auto-injects one), the resulting ?query=project:<slug> <user-query> is malformed search syntax and the Events API rejects it with 400 Bad Request. This is the same root cause as #1317 (slug scoping via query syntax instead of the project= parameter) but surfaces as a 400 instead of empty data: [].

Evidence

Sentry telemetry (sentry/cli project) shows two long-lived issue groups entirely caused by this pattern:

  • CLI-R2 — ApiError: Failed to list logs: 400 Bad Request — 316 events, first seen 2026-05-03, still active (lastSeen 2026-07-30)
  • CLI-1TQ — same title — 16 events

Every sampled event's HTTP breadcrumb shows the same malformed query, e.g.:

GET https://us.sentry.io/api/0/organizations/nineyard/events/
  ?dataset=logs&...&query=project%3Abackground-server%20Recalc%3A%20chain

The user's --query "Recalc: chain" is being naively concatenated after project:<slug>. The Events API doesn't accept that as valid search syntax (two search tokens smashed together without proper operators/parens) and returns 400.

Workaround

Pass the numeric project id instead of the slug:

sentry log list <org>/<project-id> --query "Recalc: chain"

Fix direction

Mirror #1317 / PR #312: resolve the slug to its numeric project ID and pass it via the project query parameter (Array<number>) instead of injecting project:<slug> into the search query. After the fix, the same call becomes ?query=Recalc%3A%20chain&project=<id> — no concatenation, no 400.

Already addressed for log list and log view by #1318.

Activity

  1. added
    bug
    jared
    on Jul 30, 2026
  2. jared-outpost commented on Jul 30, 2026

    @jared-outpost
    Contributor

    This is the same root cause as #1317 and is already fixed by #1318, which is open, approved, CI-green, and marked Closes #1319.

    #1318 replaces the project:<slug> query-string scoping with the numeric project param in both code paths #1319 references:

    • listLogs in src/lib/api/logs.ts (the log list path) — the naive project:<slug> <user-query> concatenation that produced the 400 is gone; the query is now just the user query with project=<id>.
    • getLogsBatch (the log view path) — same treatment.

    No separate PR needed; this will be resolved when #1318 merges.

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

    bugjared

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions