Skip to content

fix(gitea): surface API auth error messages in Settings - #14045

Open
bbingz wants to merge 4 commits into
stablyai:mainfrom
bbingz:fix/13786-gitea-auth-error-surface
Open

bbingz wants to merge 4 commits into
stablyai:mainfrom
bbingz:fix/13786-gitea-auth-error-surface

Conversation

@bbingz

@bbingz bbingz commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bug: Gitea Settings card shows only a generic "could not authenticate" string when a configured token fails auth — even when Gitea returns an actionable body (e.g. missing read:user scope).
  • Root cause: requestJsonAtBase cancels/discards non-2xx bodies and returns null; getGiteaAuthStatus only exposes a boolean.
  • Fix: Probe /user separately, keep a redacted authError, plumb it through preflight (optional field), and show it on the Gitea integration card.

Closes #13786

Test plan

  • vitest src/main/gitea/client.test.ts + auth-error-message.test.ts + integrations-pane-status tests
  • oxlint on touched files
  • Manual: set ORCA_GITEA_API_BASE_URL + a token missing read:user; Settings → Integrations → Gitea shows the server message

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

Gitea authentication now probes the authenticated /user endpoint and preserves sanitized server error details. The authentication status, preload API, preflight harness, and renderer status types carry the optional error. Settings integration cards display the detailed error when present. Tests cover redaction, response parsing, authentication status, status propagation, and rendering.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the bug, root cause, fix, linked issue, and focused test plan. However, it does not follow the required template and omits the required Visual Proof section, ELI5, What Change… Reformat the description using the repository template. Add the missing required sections, include N/A with a reason or attach before/after visual proof, document why this approach was chosen, record manual testing and platform coverage, …
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)

Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: surfacing Gitea API authentication errors in Settings.
Linked Issues check ✅ Passed Issue #13786 requires actionable Gitea authentication errors, safe redaction, and a generic fallback. probeGiteaAuthenticatedUser reads non-2xx /user bodies, extracts message or error, sanitiz…
Out of Scope Changes check ✅ Passed The changed files implement Issue #13786 across the Gitea client, preflight API, settings status mapping, and Gitea integration card. The added and updated tests verify this data path and error handli…
Full details: Description check

Explanation

The description explains the bug, root cause, fix, linked issue, and focused test plan. However, it does not follow the required template and omits the required Visual Proof section, ELI5, What Changed, Why, Notes, checklist items, AI Disclosure, Review, and cross-platform or build verification details.

Resolution

Reformat the description using the repository template. Add the missing required sections, include N/A with a reason or attach before/after visual proof, document why this approach was chosen, record manual testing and platform coverage, and complete the checklist or explain which checks CI will cover.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ff71fcfe-7053-45f6-acea-b6c7ecce6eb5

📥 Commits

Reviewing files that changed from the base of the PR and between 09ec516 and f3a7508.

📒 Files selected for processing (10)
  • src/main/gitea/auth-error-message.test.ts
  • src/main/gitea/auth-error-message.ts
  • src/main/gitea/client.test.ts
  • src/main/gitea/client.ts
  • src/main/ipc/preflight.test.ts
  • src/preload/api-types.ts
  • src/renderer/src/components/settings/cli-source-control-integration-cards.test.tsx
  • src/renderer/src/components/settings/integrations-pane-status.test.ts
  • src/renderer/src/components/settings/integrations-pane-status.ts
  • src/renderer/src/components/settings/token-source-control-integration-cards.tsx

Comment thread src/main/gitea/auth-error-message.ts Resolved
Comment thread src/main/gitea/auth-error-message.ts Resolved
Comment thread src/main/gitea/auth-error-message.ts Resolved
@bbingz

bbingz commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Community PR: please Approve and run workflows on head f3a7508f8a23 when convenient (fork CI stays gated). Surface Gitea API auth error messages in Settings.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@bbingz

bbingz commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Community PR: please Approve and run workflows on head c0a8b57fb8 when convenient (fork CI stays gated). Rebased onto #14403 preload split; Gitea authError lives on preflight-api.

@bbingz
bbingz force-pushed the fix/13786-gitea-auth-error-surface branch from c0a8b57 to f79beff Compare August 15, 2026 09:36
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@bbingz

bbingz commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Community PR: please Approve and run workflows on head f79beff811 when convenient (fork CI stays gated). Rebased after the #14728 preflight test split; the Gitea authError fixture now lives in preflight-test-harness.ts. Focused tests: 44 passed.

@nwparker nwparker removed the P1 label Aug 19, 2026
@bbingz
bbingz force-pushed the fix/13786-gitea-auth-error-surface branch from aef28cc to f185ed7 Compare September 20, 2026 08:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/main/gitea/auth-error-message.ts (1)

16-17: 🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | ⚡ Quick win

Sensitive Data Exposure

Reachability: External
Exploitability: Moderate
CWE: CWE-200 — Exposure of Sensitive Information to an Unauthorized Actor

Restore comprehensive query-secret redaction.

The matcher does not redact private_token, client_secret, api_key, password, or passphrase. A failed server response can include one of these URL query values in message, and the value then reaches authError for display. Extend the query-name matcher and add regression cases for each supported credential name.

Proposed fix
-    .replace(/([?&](?:access_token|token|key)=)[^&\s]+/gi, '$1[REDACTED]')
-    .replace(/(authorization\s*[:=]\s*(?:token|bearer)\s+)[^\s]+/gi, '$1[REDACTED]')
+    .replace(
+      /([?&](?:access_token|token|key|private_token|api[_-]?key|client_secret|password|passphrase)=)[^&\s]+/gi,
+      '$1[REDACTED]'
+    )
+    .replace(/(authorization\s*[:=]\s*(?:token|bearer|basic)\s+)[^\s]+/gi, '$1[REDACTED]')

Source: Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 06d8884d-d490-4218-992c-02cf19c8671a

📥 Commits

Reviewing files that changed from the base of the PR and between aef28cc93321bad59716199dbd79a28d0558539b and f185ed7.

📒 Files selected for processing (2)
  • src/main/gitea/auth-error-message.ts
  • src/main/ipc/preflight-test-harness.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@bbingz

bbingz commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and updated:

  • Ported Gitea authError status surfacing across src/main/gitea/client.ts, src/main/preflight/agent-detection.ts, src/preload/api/preflight/preflight-api.ts, src/preload/api/preflight/preflight-bridge.ts, src/renderer/src/components/integrations/source-control/integrations-pane-status.ts, and token-source-control-integration-cards.tsx.
  • Added src/main/gitea/auth-error-message.ts using readFetchResponseTextWithinLimit (4 KiB cap) and readFetchResponseJsonWithinLimit from src/shared/network/fetch-response-body.ts, fallback HTTP <status> on JSON null/empty bodies, expanded credential redaction (configured token, query params including percent-encoded keys and HTML entity &amp;/&#38;/&#x26; delimiters, URL userinfo, and a linear O(n) Authorization/Proxy-Authorization header/array scanner).
  • Added unit and integration regression coverage in auth-error-message.test.ts, client-auth-status.test.ts, and integrations-pane-status.test.ts. Verified with Vitest, oxlint, oxfmt, changed-code quality gates, pnpm tc:node, and pnpm tc:web.

@bbingz
bbingz force-pushed the fix/13786-gitea-auth-error-surface branch from f185ed7 to 333fda2 Compare November 18, 2026 06:33
@bbingz

bbingz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Fork CI for bfdc6d0c87c finished. Unit full succeeded: https://github.com/bbingz/orca/actions/runs/45414292668

The PR-description check failed once because the body had no Performance section, then succeeded after that section was added. Latest checks on that head have no remaining failure. Closing verification PR bbingz#90.

@bbingz

bbingz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Fork verification for cd8c61251c8b945a0a0c149302b9b585b8796306 finished.

Closing the fork verification PR. No queued runs were left on this branch.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Surface the actual Gitea API error when integration auth fails

4 participants