Public: anyone can read this; the crew can change it.

A new forge's model API base URL that ends in /v1 is accepted and stored without it, and the form says which form to give #12943

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Both new-forge forms now say the base omits /v1. The stripping and the refusal of a bad URL were already in the code, so I only tested them. What was already there parseApiBase in src/core/subscriptions.ts strips trailing slashes and one trailing /v1.

Notes

opened this

Both new-forge forms now say the base omits /v1. The stripping and the refusal of a bad URL were already in the code, so I only tested them.

What was already there

  • parseApiBase in src/core/subscriptions.ts strips trailing slashes and one trailing /v1. addSubscription and the spawn door in src/spawn/door.ts both call it, so https://openrouter.ai/api/v1/ is stored as https://openrouter.ai/api.
  • The door answers 422 with modelEndpoint named when the URL is not valid. The Anthropic default (no base URL) is untouched: an empty base stays empty.

What changed

  • The hint on /new-forge (src/web/pages/new-forge.ts) now reads "The base omits /v1: https://openrouter.ai/api, not …/api/v1 (a trailing /v1 is dropped)…".
  • The TUI form (src/tui/screens/newforge.ts) says "Base omits /v1 (https://openrouter.ai/api)…".
  • test/api-base-v1.test.ts checks that https://x/api/v1/ becomes https://x/api, that ftp://x and http://x are refused, and that both forms carry the "omits /v1" line. The hint check only reads the two source files for that text. It does not render the page or the TUI.
  • test/spawn-keys.test.ts gains a case where POST /api/v1/forges with ftp://x returns 422 naming modelEndpoint.

What I left alone

  • The issue asks to reject non-http(s) URLs. The existing rule accepts https only, and I kept it, since a model key sent over plain http would be exposed. The cost is that a local http:// gateway is refused.
  • I did not add a way to keep a gateway's real /v1. If one needs it, that is a separate change.

Checks

  • bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts pass.
  • test/api-base-v1.test.ts, spawn-keys, new-forge and the TUI new-forge tests pass: 55 tests.
  • The sandbox blocked some outbound *.forge.test connections during the run.

How to try it: open /new-forge, open More, and read the API base URL hint. Paste https://openrouter.ai/api/v1 with a key and the stored base is https://openrouter.ai/api.

🤖 Generated with Claude Code

Closes #12941

3 earlier comments
commented

Both new-forge forms now say the base omits /v1. The stripping and the refusal of a bad URL were already in the code, so I only tested them.

What was already there

  • parseApiBase in src/core/subscriptions.ts strips trailing slashes and one trailing /v1. addSubscription and the spawn door in src/spawn/door.ts both call it, so https://openrouter.ai/api/v1/ is stored as https://openrouter.ai/api.
  • The door answers 422 with modelEndpoint named when the URL is not valid. The Anthropic default (no base URL) is untouched: an empty base stays empty.

What changed

  • The hint on /new-forge (src/web/pages/new-forge.ts) now reads "The base omits /v1: https://openrouter.ai/api, not …/api/v1 (a trailing /v1 is dropped)…".
  • The TUI form (src/tui/screens/newforge.ts) says "Base omits /v1 (https://openrouter.ai/api)…".
  • test/api-base-v1.test.ts checks that https://x/api/v1/ becomes https://x/api, that ftp://x and http://x are refused, and that both forms carry the "omits /v1" line. The hint check only reads the two source files for that text. It does not render the page or the TUI.
  • test/spawn-keys.test.ts gains a case where POST /api/v1/forges with ftp://x returns 422 naming modelEndpoint.

What I left alone

  • The issue asks to reject non-http(s) URLs. The existing rule accepts https only, and I kept it, since a model key sent over plain http would be exposed. The cost is that a local http:// gateway is refused.
  • I did not add a way to keep a gateway's real /v1. If one needs it, that is a separate change.

Checks

  • bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts pass.
  • test/api-base-v1.test.ts, spawn-keys, new-forge and the TUI new-forge tests pass: 55 tests.
  • The sandbox blocked some outbound *.forge.test connections during the run.

How to try it: open /new-forge, open More, and read the API base URL hint. Paste https://openrouter.ai/api/v1 with a key and the stored base is https://openrouter.ai/api.

🤖 Generated with Claude Code

commented

I added a Looks: /new-forge line in a new commit, which is what the failed check asked for, and pushed. I haven't seen the forge's re-run yet.

The failed rule wanted a before/after look for src/web/pages/new-forge.ts. No code or test changed in this push, so the earlier local gate, tsc and test results still apply.

The pull description is unchanged: both new-forge forms now say the API base omits /v1. The stripping and the https-only refusal were already in the code, and the new tests cover them.

🤖 Generated with Claude Code

commented

I pushed a new commit with a No look: line, and I haven't seen the check re-run yet. Only /new-forge is wrong here: it isn't in app.looks in forge.json, so the previous Looks: /new-forge line couldn't pass.

I chose No look over adding the page to app.looks. The only change to that page is one hint sentence inside the collapsed More section, which a page picture wouldn't show. The No look line says exactly that.

No code or tests changed, so the earlier local results still apply (tsc, scripts/gate.ts, design lint and the 55 targeted tests all passed).

The pull description is unchanged. Both new-forge forms now say the API base omits /v1. The /v1 stripping and the https-only refusal were already in the code, and the new tests cover them.

🤖 Generated with Claude Code

commented

The API base hint now says "omit /v1" once on both forms, and the new tests render the screens instead of reading source. The pushed tests pass, tsc --noEmit and bun scripts/design-lint.ts are clean, and scripts/gate.ts is not in this clone.

  • Web hint: it now reads "Leave off /v1: https://openrouter.ai/api. Empty uses your AI's own service." (your suggested wording).
  • TUI hint: it now reads "Omit /v1: https://openrouter.ai/api. Empty = your AI's own service." Your suggested "Omit /v1, e.g. …" still clipped at 80 columns in the headless terminal, because the screen's margin leaves about 70 characters. I dropped the "e.g." so it fits. The test asserts the full hint is on the rendered screen at 80 columns.
  • Hint tests: the source-grepping test is gone. test/api-base-v1.test.ts renders the TUI screen at 80 columns and asserts the hint appears whole. test/new-forge.test.ts fetches /forges/new and asserts the web hint appears in the HTML.
  • End-to-end test: test/spawn-keys.test.ts now POSTs a real spawn with modelEndpoint https://x/api/v1/ and opens the child's sealed key. Its stored apiBase is https://x/api. I used a real spawn rather than a dry run because the dry-run plan doesn't show the base.

The https-only rule is unchanged, and so is the ftp:// 422 test.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs