Skip to content

Use canonical API host and reject credentialed redirects - #34

Merged
sidneyswift merged 2 commits into
mainfrom
codex/cli-canonical-no-redirect
Nov 17, 2026
Merged

sidneyswift merged 2 commits into
mainfrom
codex/cli-canonical-no-redirect

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Result

GET and POST now reject redirects before sending a second request, protecting x-api-key and POST bodies from forwarding. The default is https://api.recoupable.dev; RECOUP_API_URL still selects the initial trusted endpoint. Existing PR23 and its broader parity changes are untouched. Open PR33 (6b5f458) separately refactors both verbs into a shared request helper that omits redirect rejection. It is not a prerequisite: future composition must keep non-following redirect handling and explicit 3xx rejection in that helper and retain the native-fetch regression tests. Neither existing PR was modified.

Validation

Local native-fetch tests reproduced 20 redirect failures plus the old-default failure before implementation. All 301/302/303/307/308 GET/POST redirects, both same-origin and cross-origin, now reject with zero destination requests. Direct query/body/key behavior remains intact. Fake credentials and loopback HTTP servers only.

112 tests pass; one candidate-guide check skips unless its path is supplied (passed separately against the Docs companion). TypeScript and build pass. Independent review passed; final-head CI required. The immutable historical guide fixture is unchanged.

Release boundary

Source repair only. No npm publish, installation, credential changes, approved-client replacement or Context identity preflight. Coordinator owns merge. Existing main publish workflow runs automatically on main pushes, so merging is publication-impacting; this PR does not change that workflow. Docs companion pins this source and states publication/installation remain unverified.

Final diagnostic correction: manual non-following fetch rejects 3xx with a fixed safe message, preserves original network failures and existing HTTP/API errors, and exposes no request or redirect details. Independent exact-commit review passed. Docs pins CLI 213de51; final-head CI is distinct from earlier green results.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e35c9f42-6acb-47bc-9900-0d1ed87f44af
  • 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T21:18:45.455970Z b65a807 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/client.ts">

<violation number="1" location="src/client.ts:26">
P2: `redirect: "error"` makes `fetch` throw a generic `TypeError: fetch failed` on any 3xx, and the CLI prints only that message. A user whose `RECOUP_API_URL` redirects will see `Error: fetch failed` with no hint about the cause. Catch the redirect error in a shared helper and rethrow with the URL and the reason.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/client.ts Outdated

const response = await fetch(url.toString(), {
method: "GET",
redirect: "error",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: redirect: "error" makes fetch throw a generic TypeError: fetch failed on any 3xx, and the CLI prints only that message. A user whose RECOUP_API_URL redirects will see Error: fetch failed with no hint about the cause. Catch the redirect error in a shared helper and rethrow with the URL and the reason.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/client.ts, line 26:

<comment>`redirect: "error"` makes `fetch` throw a generic `TypeError: fetch failed` on any 3xx, and the CLI prints only that message. A user whose `RECOUP_API_URL` redirects will see `Error: fetch failed` with no hint about the cause. Catch the redirect error in a shared helper and rethrow with the URL and the reason.</comment>

<file context>
@@ -23,6 +23,7 @@ export async function get(
 
   const response = await fetch(url.toString(), {
     method: "GET",
+    redirect: "error",
     headers: {
       "x-api-key": getApiKey(),
</file context>

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.

1 participant