Skip to content

Capture and surface GitLab API response bodies on errors#30

Merged
LeviXIII merged 1 commit into
mainfrom
feat/api-error-details
May 13, 2026
Merged

Capture and surface GitLab API response bodies on errors#30
LeviXIII merged 1 commit into
mainfrom
feat/api-error-details

Conversation

@JonahBraun
Copy link
Copy Markdown
Contributor

@JonahBraun JonahBraun commented May 5, 2026

Capture and surface GitLab API response bodies on errors.

GitLab API failures previously bubbled up as opaque "Forbidden" / "Unauthorized" status text, with no way to see the actual reason (expired password, missing scope, etc.). This change introduces a structured GitLabApiError that carries the response body, URL, method, and operation label, plus a centralized assertOk helper that logs the full body to the extension host log. Pairs with codex-editor's "Copy Error Details" toast — both should ship together so users can paste the body to support.

New log message shows actual error:
Screenshot 2026-05-05 at 10 56 24 AM

Changes

  • Add GitLabApiError in src/utils/apiError.ts with status/url/method/body fields
  • Add assertOk private helper in GitLabService that logs and throws on non-OK responses
  • Replace ad-hoc !response.ok error-throw blocks across 8 callsites with assertOk

Test plan

  • Hit an endpoint with an invalid token; verify the host log shows the GitLab response body
  • Verify a thrown GitLabApiError carries status, url, method, body accessible to callers
  • Verify file-not-found (404) in getRepositoryFile still throws "File not found: "
  • Verify getRepositoryTree returns [] on 404 unchanged

Every GitLab API call in GitLabService now goes through a shared assertOk
helper that reads the response body, logs it to the extension host log,
and throws a typed GitLabApiError carrying status, statusText, url,
method, and body. Without this, opaque HTTP statusText was the only
diagnostic available. The new error class lets codex-editor's sync toast
surface a copyable error report to support staff.
@LeviXIII LeviXIII merged commit c73f45b into main May 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants