Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(cli): name the proxy when a reset request is redirected
KageBinary680942079a20
diff --git a/docs/api/README.md b/docs/api/README.mdindex 375f55e1..338f36a7 100644--- a/docs/api/README.md+++ b/docs/api/README.md@@ -633,7 +633,9 @@ The client never follows redirects on any reset request (`begin`, `status`,or either sync path): a 3xx stops with the same reconciliation warning ratherthan replaying the POST or treating a redirected 404 as an old backend, so aremote endpoint must be configured as the direct backend URL, not one a proxy-redirects (e.g. `http://` behind an HTTPS redirect).+redirects (e.g. `http://` behind an HTTPS redirect). For a redirected start or+sync request the error names the target's origin and suggests setting+`IX_ENDPOINT` to the direct URL.A 404 on `begin` falls back to the sync path (old backend). A 404 on `status`does **not**: the op ledger is in-process, so a restart, a different replica ordiff --git a/docs/security/reset-outcome-reconciliation.md b/docs/security/reset-outcome-reconciliation.mdindex 248cbcba..e5a3f262 100644--- a/docs/security/reset-outcome-reconciliation.md+++ b/docs/security/reset-outcome-reconciliation.md@@ -34,6 +34,10 @@ trigger sync fallback. A refused redirect target also says nothing about whetherthe initial reset ran. Redirect responses therefore require reconciliation, withthe original operation ID retained when known. Configure the direct backendendpoint before any operator-approved recovery; do not repeat an uncertain reset.+Because the backend itself never redirects, a redirected start or sync request+also names the redirect target's origin (never its path or query) and points at+`IX_ENDPOINT` as the likely fix; a redirected status poll keeps the operation ID+instead, since its start was already accepted.Authentication errors at start remain errors. This patch does not add tenantheaders, credentials or an authorization bypass; the remote transport mustdiff --git a/ix-cli/src/client/__tests__/reset-redirect.test.ts b/ix-cli/src/client/__tests__/reset-redirect.test.tsindex 8c62efc2..755a503b 100644--- a/ix-cli/src/client/__tests__/reset-redirect.test.ts+++ b/ix-cli/src/client/__tests__/reset-redirect.test.ts@@ -107,6 +107,27 @@ describe.each(["reset", "resetCode"] as const)("%s never follows a reset redirecexpect(remote.seen).toEqual([{ method: "POST", path: `${stem}/async`, body: "{}" }]);});+ it("points a proxy redirect at the target origin without its path or query", async () => {+ const remote = await fixture((_request, response) => {+ response.writeHead(308, { location: "https://ix.example.com/v1/reset/async?token=secret" }); response.end();+ });+ const failure = await remoteClient(remote.endpoint)[method]().catch((error: unknown) => error);+ const message = (failure as Error).message;+ expect(message).toContain("redirected (308 to https://ix.example.com)");+ expect(message).toContain("Do not repeat the reset");+ expect(message).toContain(`a proxy at ${remote.endpoint} most likely did`);+ expect(message).toContain("IX_ENDPOINT");+ expect(message).not.toContain("secret");+ });++ it("resolves a relative Location against the endpoint in the hint", async () => {+ const local = await fixture((_request, response) => {+ response.writeHead(307, { location: "/elsewhere" }); response.end();+ });+ await expect(new IxClient(local.endpoint)[method]())+ .rejects.toThrow(`synchronous reset route redirected (307 to ${local.endpoint})`);+ });+it.each([302, 303])("does not interpret a redirected %s/404 as an absent async route", async status => {const remote = await fixture((request, response) => {if (request.path === `${stem}/async`) {diff --git a/ix-cli/src/client/api.ts b/ix-cli/src/client/api.tsindex 702b1546..cb32682f 100644--- a/ix-cli/src/client/api.ts+++ b/ix-cli/src/client/api.ts@@ -481,7 +481,7 @@ export class IxClient {if (beginResp.status >= 300 && beginResp.status < 400) {await beginResp.body?.cancel().catch(() => {});- throw this.resetReconciliationError(`The start route redirected (${beginResp.status}).`);+ throw this.resetRedirectError("start route", beginResp);}if (beginResp.status === 404) {return this.runResetSync(syncPath);@@ -548,13 +548,14 @@ export class IxClient {throw this.resetReconciliationError("Completion was not confirmed within 15 minutes.", opId);}- private resetReconciliationError(reason: string, opId?: string, cause?: unknown): Error {+ private resetReconciliationError(reason: string, opId?: string, cause?: unknown, hint?: string): Error {const operation = opId ? ` (operation ${opId})` : "";// Carry `cause` so IX_DEBUG=1 can still show the underlying transport// failure — swallowing it left no way to tell these outcomes apart.const error = new Error(`${reason}${operation} Graph or pipeline changes may already have occurred. ` +- "Do not repeat the reset until an administrator has reconciled its effects and operation records.",+ "Do not repeat the reset until an administrator has reconciled its effects and operation records." ++ (hint ? ` ${hint}` : ""),cause === undefined ? undefined : { cause });// Marked so error rendering does not reclassify this by its cause and// print "start the backend, then retry" over a do-not-repeat warning.@@ -562,6 +563,26 @@ export class IxClient {return error;}+ // The backend never redirects, so a 3xx almost always comes from a proxy in+ // front of it (typically http:// upgraded to https://), and every other+ // command follows it silently. Say so, or the endpoint looks healthy+ // everywhere except reset. Only origins are shown: a Location path or query+ // (and endpoint userinfo) may carry credentials.+ private resetRedirectError(route: string, resp: Response): Error {+ let target = "";+ try {+ const location = resp.headers.get("location");+ const origin = location ? new URL(location, resp.url || this.endpoint).origin : "null";+ if (origin !== "null") target = ` to ${origin}`;+ } catch { /* unparseable Location: omit the target */ }+ let endpoint = this.endpoint;+ try { endpoint = new URL(this.endpoint).origin; } catch { /* keep as configured */ }+ return this.resetReconciliationError(+ `The ${route} redirected (${resp.status}${target}).`, undefined, undefined,+ `The Ix backend does not send redirects, so a proxy at ${endpoint} most likely did. ` ++ "Set IX_ENDPOINT (or `endpoint` in ~/.ix/config.yaml) to the backend's direct URL.");+ }+private async runResetSync(syncPath: string): Promise<{ ok: boolean; message: string }> {const resp = await fetch(`${this.endpoint}${syncPath}`, {method: "POST",@@ -572,7 +593,7 @@ export class IxClient {});if (resp.status >= 300 && resp.status < 400) {await resp.body?.cancel().catch(() => {});- throw this.resetReconciliationError(`The synchronous reset route redirected (${resp.status}).`);+ throw this.resetRedirectError("synchronous reset route", resp);}if (!resp.ok) {const text = await resp.text();