GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — clef-proxy: the upstream half of PR #691's fix has no regression test — and the hardcoded gateway URL makes it untestable · Issue #692 · developing-today/code

clef-proxy: the upstream half of PR #691's fix has no regression test — and the hardcoded gateway URL makes it untestable #692

New issue
Copy link
New issue
Copy link
Closed
#3172
Closed
clef-proxy: the upstream half of PR #691's fix has no regression test — and the hardcoded gateway URL makes it untestable#692
#3172
Copy link
Assignees
dezren39
Labels
effort/sSmall: expected under 2 hours of workkind/testTest coverage, test infrastructure, or test-only fixesmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/pr-diff-reviewFiled by the pr-diff-review jobtask/triageQueue packet kind: verify, reproduce, and route this item

Description

@dezren39
dezren39
opened on Oct 23, 2026
Issue body actions

Finding

PR #691 fixed both halves of #690 in bin/clef-proxy.mjs, but only the client-body half got a regression test. The upstream half — a non-JSON or null/scalar gateway response is reported as an upstream failure preserving the upstream status instead of throwing into a 500 — has no test that can fail if it regresses, and as written it cannot be tested at all: the gateway URL is hardcoded, so no stub upstream can be injected.

Evidence

  • PR: fix(clef-proxy): malformed client JSON is a 400, not a 500 (#690) #691 (merged 2026-10-23T21:39:55Z, merge commit 8e05af24341b321779851bc824177b14cfd57b9f, commit 02183adb78c00e20fab4bebb2e7100a6f4e58bcc, fixes clef-proxy: invalid client JSON returns 500 instead of 400 — body parse shares the upstream try/catch, non-JSON upstream is masked, and there are no tests #690, now CLOSED)
  • Upstream guard on current main 8e05af24 (bin/clef-proxy.mjs:157-165, blob b61de077 cross-checked via gh api): cfData starts null, await cfRes.json() is in its own try {} catch {}, and the success check is cfRes.ok && cfData?.success && cfData.result?.answers; the failure branch answers cfRes.status >= 400 ? cfRes.status : 502.
  • The new test file's own header says the upstream is out of scope (bin/clef-proxy.test.mjs:4-6): "The proxy forwards valid requests to the Cloudflare AI gateway, which these tests never reach: they cover the paths that answer locally". Its four subtests are health 200, invalid JSON 400, non-object JSON 400, missing token 401 — none reaches the fetch. Verified this run (pr-diff-review): node --test bin/clef-proxy.test.mjs passes 5/5 on current main, and reverting only the upstream guard (unguarded cfRes.json() / cfData.success) would fail none of them.
  • The gateway base is not overridable (bin/clef-proxy.mjs:141): const cfUrl = \https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/workers-ai/run/${model}\``. Account, gateway and token all come from env/config (getCredentials, :56-73), but the host does not, so a test cannot point the proxy at a local stub gateway without a code change first.
  • clef-proxy: invalid client JSON returns 500 instead of 400 — body parse shares the upstream try/catch, non-JSON upstream is masked, and there are no tests #690's acceptance criteria required tests only for the local paths (health / invalid JSON 400 / missing token 401), so the issue closed with the upstream behaviour — two of its own acceptance bullets — unpinned. Same pattern as design-code-proxy: the streaming half of PR #685's Content-Length fix has no regression test — the stub never sets Content-Length on SSE responses #688 (the untested streaming half of PR fix(design-code-proxy): don't forward the backend's Content-Length for re-serialized bodies (#684) #685's design-code-proxy fix).

Why it matters

The upstream guard is the half that fires exactly when Cloudflare is misbehaving — an HTML 502/429 page or a malformed gateway body is when clients most need the real upstream status instead of a misleading JSON-parse 500. Today the code is correct; what is missing is the pin that keeps it correct, and the hardcoded gateway host means a future contributor cannot add that pin without first refactoring the URL construction.

Single-repo: clef-proxy and the gateway.ai.cloudflare.com URL exist only in this repo (git grep across the local clones of developing-today/opencode, developing-today/openchamber and dezren39/nix finds neither).

Acceptance criteria

  • The gateway base URL is overridable for tests (e.g. an env var such as CLEF_PROXY_GATEWAY_BASE_URL / CLOUDFLARE_GATEWAY_BASE_URL defaulting to https://gateway.ai.cloudflare.com/v1), or an equivalent fetch/stub injection exists; production behaviour with the override unset is byte-identical.
  • New tests in bin/clef-proxy.test.mjs run the proxy against a stub gateway and cover at least: a non-JSON upstream body with an error status (client gets that status / 502 upstream failure, not a JSON-parse 500), and a null (or scalar) upstream JSON body (no throw on cfData.success, reported as an upstream failure).
  • Ablation: with the upstream guard reverted (unguarded await cfRes.json() and cfData.success), the new tests fail; with the guard in place, the full clef-proxy suite passes (node --test bin/clef-proxy.test.mjs).

Activity

Next
  1. github-actions
    assigned
    dezren39
    on Oct 23, 2026
  2. dezren39
    added
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/pr-diff-reviewFiled by the pr-diff-review job
    status/needs-triageNot yet triaged; needs a first look
    on Oct 25, 2026
  3. dezren39 commented on Oct 26, 2026

    @dezren39
    dezren39
    on Oct 26, 2026
    MemberAuthor
    More actions

    Intake review

    Still live (verified this run, fleet monitor): bin/clef-proxy.mjs on current main still hardcodes the gateway URL at line 160 (https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/workers-ai/run/${model}) with no env override, and the upstream guard (cfRes.ok && cfData?.success && cfData.result?.answers, line ~184) is present but still has no test that can reach it — the test file's local-paths-only scope is unchanged.

    Related: PR #691 / closed #690 (the fix whose upstream half this pins), #688 (the same untested-streaming-half pattern in design-code-proxy).

    Notes / risks: the prerequisite refactor (gateway base URL from env/config, defaulting to the current hardcoded value) is the only production change needed; keep the default byte-identical so deployment behaviour does not move.

    Suggested approach: add a CLEF_GATEWAY_BASE-style override in getCredentials/config, point the test suite at a local stub gateway, and add subtests for non-JSON upstream body, null/scalar JSON, and upstream 4xx/5xx status preservation.

    Labels normalized by the fleet monitor: kind/test, priority/normal, effort/s.

  4. dezren39
    added
    kind/testTest coverage, test infrastructure, or test-only fixes
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    on Oct 26, 2026
  5. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    🤖 Agent note · picked up

    • Agent: queue worker (repo-worker-code), lane D
    • Session / ID: queue task 1068 (triage, lane D shift 2026-10-31 12:14 CDT)
    • Found via: queue claim
    • Task: Triage clef-proxy: the upstream half of PR #691's fix has no regression test — and the hardcoded gateway URL makes it untestable #692 — confirm the upstream guard behaviour and the hardcoded-gateway untestability claim on current main, and propose an injection seam (no implementation)
    • Expectation: effort s — done = findings posted on clef-proxy: the upstream half of PR #691's fix has no regression test — and the hardcoded gateway URL makes it untestable #692 with a pinned seam proposal and a routed follow-up, task completed triaged
    • Links: issue clef-proxy: the upstream half of PR #691's fix has no regression test — and the hardcoded gateway URL makes it untestable #692
  6. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    🤖 Agent note · triage findings (queue task 1068, lane D)

    Verdict: CONFIRMED on current main 47214f1c — verified by direct read of bin/clef-proxy.mjs this run (line numbers moved since filing; the code is byte-equivalent):

    • Guard behaviour (as filed): :246-255 — cfData starts null, await cfRes.json() sits in its own try {} catch {}, success requires cfRes.ok && cfData?.success && cfData.result?.answers, and the failure branch answers cfRes.status >= 400 ? cfRes.status : 502. A non-JSON or null/scalar gateway body is reported as an upstream failure preserving the upstream status — the fix(clef-proxy): malformed client JSON is a 400, not a 500 (#690) #691 upstream half is present and correct.
    • Untestability (as filed): :227 — cfUrl is built from a hardcoded https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/workers-ai/run/${model}. Account/gateway/token all resolve env-first (getCredentials, :75/:79/:88), and even the listen host is env-overridable (CLEF_PROXY_HOST, :9) — but the gateway host/base is not, so no stub upstream can be injected. bin/clef-proxy.test.mjs's own header still states the tests "never reach" the upstream; its subtests cover only the local paths (health / 400 / 401), so reverting the guard would fail none of them.
    • No open PR references clef-proxy: the upstream half of PR #691's fix has no regression test — and the hardcoded gateway URL makes it untestable #692 (searched this run).

    Seam proposal (pinned for the follow-up task — not implemented here): follow the file's own env-first convention: const gatewayBase = process.env.CLEF_PROXY_GATEWAY_BASE || 'https://gateway.ai.cloudflare.com' and build cfUrl as ${gatewayBase}/v1/${accountId}/${gatewayId}/workers-ai/run/${model}. Default behaviour is byte-identical. The existing test harness already spawns the proxy as a subprocess with a controlled env/HOME, so with this seam the upstream tests need no export refactor: stand up a stub HTTP server on 127.0.0.1, point CLEF_PROXY_GATEWAY_BASE at it, POST a valid body, and pin: (1) upstream 502 with an HTML/non-JSON body → proxy answers 502 (not 500); (2) upstream 200 with JSON null → 502; (3) upstream 200 with a scalar body → 502; (4) upstream 200 with {success:true,result:{answers}} → 200 with the answers (happy path pinned too).

    A small_fix follow-up task (seam + the four upstream regression tests) is being enqueued from this triage.

  7. 7 remaining items

  8. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    queue/queuedHas a queued queue task
    on Oct 31, 2026
  9. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    agent-note:v1 — task 4596 implemented by Lane A. PR opened @af1424238: CLEF_PROXY_GATEWAY_BASE seam (Cloudflare default, cfUrl shape unchanged) + stub-upstream regression tests (non-JSON 502 / null 200 / scalar 200 / happy path); node --test bin/clef-proxy.test.mjs 10/10 on the laptop. Parking on CI + Codex review.

  10. dezren39
    added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    on Oct 31, 2026
  11. dezren39
    added a commit that references this issue on Oct 31, 2026

    Merge pull request #3172 from developing-today/queue/4596-692-clef-pr…

    fe62dc7
  12. dezren39
    closed this as completedin #3172on Oct 31, 2026
  13. dezren39
    removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Oct 31, 2026
  14. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    🤖 Agent note · done

    • Agent: repo-worker-code, OpenChamber scheduled lane
    • Session / ID: queue task 4596
    • Task: Resumed and verified PR test(clef-proxy): CLEF_PROXY_GATEWAY_BASE seam + upstream guard regression tests (#692) #3172; merged as fe62dc7 and issue closed.
    • Verification: node --test bin/clef-proxy.test.mjs passed 10/10; Codex review of implementation commit af14242 had no findings. CodeRabbit skipped; no passing CI check was observed.
    • Links: test(clef-proxy): CLEF_PROXY_GATEWAY_BASE seam + upstream guard regression tests (#692) #3172
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

effort/sSmall: expected under 2 hours of workkind/testTest coverage, test infrastructure, or test-only fixesmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/pr-diff-reviewFiled by the pr-diff-review jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.