Skip to content

bug: API error messages show [object Object] instead of meaningful detail #256

Description

@BYK

Description

When the Sentry API returns an error (e.g., 404 for a nonexistent resource), the CLI displays [object Object] instead of the actual error detail.

Steps to Reproduce

sentry org view nonexistent-org-xyz

Actual output:

Error: Failed to get organization: 404 Not Found
  [object Object]

Expected output:

Error: Failed to get organization: 404 Not Found
  The requested resource does not exist

Also seen with:

  • sentry issue view sentry/NONEXISTENT-123 (any 404 error)

Root Cause

In src/lib/api-client.ts:79-94, the throwApiError function attempts to extract a detail property from the error object:

const detail =
  error && typeof error === "object" && "detail" in error
    ? String((error as { detail: unknown }).detail)
    : String(error);

When the @sentry/api SDK returns an error object that doesn't have a detail property (or the error is the raw response body as a plain object), the fallback String(error) produces [object Object] for any plain object.

Proposed Fix

Improve the fallback in throwApiError to handle plain objects by serializing them to JSON:

const detail =
  error && typeof error === "object" && "detail" in error
    ? String((error as { detail: unknown }).detail)
    : error && typeof error === "object"
      ? JSON.stringify(error)
      : String(error);

Alternatively, inspect what the @sentry/api SDK actually returns as the error shape on 4xx responses and extract the most useful field (e.g., detail, message, or the response body text).

Files

  • src/lib/api-client.ts:79-94throwApiError function
  • src/lib/errors.ts:44-68ApiError class and its format() method

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions