[PR #8357] [MERGED] fix(connections): send a default User-Agent on provider requests (#8353) #8313

Closed
opened 2026-10-27 06:07:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8357
Author: @Promansis
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @Promansis

Base: staging ← Head: fix(connections)/8353-default-user-agent


📝 Commits (2)

  • c80f7d3 fix(connections): send a default User-Agent on provider requests (#8353)
  • f1129e3 Merge remote-tracking branch 'upstream/staging' into fix(connections)/8353-default-user-agent

📊 Changes

4 files changed (+53 additions, -6 deletions)

View changed files

📝 packages/server/src/routes/connections.routes.ts (+3 -2)
📝 packages/server/src/services/llm/base-provider.ts (+7 -2)
📝 packages/server/src/utils/security.ts (+10 -1)
📝 scripts/regressions/safe-fetch-response-activity.regression.ts (+33 -1)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

Closes #8353

Why this change

Featherless's edge answers 404 Gone. to requests whose User-Agent is node or undici, which is what Node's fetch sends by default. Engine set no User-Agent on provider calls, so Fetch Models on a Custom (OpenAI-compatible) connection to https://api.featherless.ai/v1 failed with Provider returned 404: Gone., while SillyTavern worked with the same URL. The Test button and chat completions go through the same path.

Checked with curl against the endpoint and a bad key: -A node and -A undici return 404 Gone.; -A MarinaraEngine/2.5.1 reaches the normal 401 auth error.

What changed

  • utils/security.ts: new requestHeadersWithDefaultUserAgent(), which sets User-Agent: MarinaraEngine/<APP_VERSION> only when the caller did not set one.
  • services/llm/base-provider.ts: llmFetch applies it, covering chat and embedding generation.
  • routes/connections.routes.ts: the /models fetch and the connection-test fetch apply it.
  • safe-fetch-response-activity.regression.ts: one case on the existing loopback server asserts llmFetch and the discovery header helper send the default User-Agent (not node) and that a caller-supplied User-Agent is kept.

Deliberately not changed: safeFetch itself and requestHeadersWithIdentityEncoding. Both are shared by about 60 other callers (video, media, TTS, ChatGPT auth, OpenCode), and a global default would alter the OpenCode redirect-hop assertion. Every other caller sends the same headers as before. OpenCode's own User-Agent, OpenRouter attribution, accept-encoding: identity and the SSRF policy are unchanged.

Validation

Local, on f1129e3cc (feature commit merged with upstream/staging at 105a707a1):

  • The new case fails with 'node' when the base-provider.ts change is removed, and passes with it.

  • node scripts/run-regressions.mjs --filter for safe-fetch-response-activity, opencode-session, security (30), connection (10), provider (9), llm, openai, anthropic and openrouter: all pass.

  • pnpm format:check passes; pnpm lint reports 0 errors (1 existing client warning); pnpm --filter @marinara-engine/server build exits 0.

  • Not run: the full pnpm check and the complete regression suite. I did not test against a real Featherless key.

  • pnpm check passes locally

  • Container (Docker / Podman) built and ran without issue

  • Ran the app, clicked through the changes manually

  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)

  • Above manual verification completed (describe below)

  • Read and followed CONTRIBUTING.md

Manual verification notes

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

No UI change.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8357 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix(connections)/8353-default-user-agent` --- ### 📝 Commits (2) - [`c80f7d3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c80f7d3d23a418ca1558326a61331cf650cf406b) fix(connections): send a default User-Agent on provider requests (#8353) - [`f1129e3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f1129e3cc56faf55b0cdc486d5972049a1c66d52) Merge remote-tracking branch 'upstream/staging' into fix(connections)/8353-default-user-agent ### 📊 Changes **4 files changed** (+53 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/connections.routes.ts` (+3 -2) 📝 `packages/server/src/services/llm/base-provider.ts` (+7 -2) 📝 `packages/server/src/utils/security.ts` (+10 -1) 📝 `scripts/regressions/safe-fetch-response-activity.regression.ts` (+33 -1) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Closes #8353 ## Why this change Featherless's edge answers `404 Gone.` to requests whose `User-Agent` is `node` or `undici`, which is what Node's `fetch` sends by default. Engine set no User-Agent on provider calls, so Fetch Models on a Custom (OpenAI-compatible) connection to `https://api.featherless.ai/v1` failed with `Provider returned 404: Gone.`, while SillyTavern worked with the same URL. The Test button and chat completions go through the same path. Checked with curl against the endpoint and a bad key: `-A node` and `-A undici` return `404 Gone.`; `-A MarinaraEngine/2.5.1` reaches the normal `401` auth error. ## What changed - `utils/security.ts`: new `requestHeadersWithDefaultUserAgent()`, which sets `User-Agent: MarinaraEngine/<APP_VERSION>` only when the caller did not set one. - `services/llm/base-provider.ts`: `llmFetch` applies it, covering chat and embedding generation. - `routes/connections.routes.ts`: the `/models` fetch and the connection-test fetch apply it. - `safe-fetch-response-activity.regression.ts`: one case on the existing loopback server asserts `llmFetch` and the discovery header helper send the default User-Agent (not `node`) and that a caller-supplied User-Agent is kept. Deliberately not changed: `safeFetch` itself and `requestHeadersWithIdentityEncoding`. Both are shared by about 60 other callers (video, media, TTS, ChatGPT auth, OpenCode), and a global default would alter the OpenCode redirect-hop assertion. Every other caller sends the same headers as before. OpenCode's own User-Agent, OpenRouter attribution, `accept-encoding: identity` and the SSRF policy are unchanged. ## Validation Local, on `f1129e3cc` (feature commit merged with `upstream/staging` at `105a707a1`): - The new case fails with `'node'` when the `base-provider.ts` change is removed, and passes with it. - `node scripts/run-regressions.mjs --filter` for `safe-fetch-response-activity`, `opencode-session`, `security` (30), `connection` (10), `provider` (9), `llm`, `openai`, `anthropic` and `openrouter`: all pass. - `pnpm format:check` passes; `pnpm lint` reports 0 errors (1 existing client warning); `pnpm --filter @marinara-engine/server build` exits 0. - Not run: the full `pnpm check` and the complete regression suite. I did not test against a real Featherless key. - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) No UI change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-27 06:07:37 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8313
No description provided.