Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ _In development — bullets added per PR; finalized at release._

- **fix(dashboard):** show custom provider given-name instead of internal id across dashboard pages — cache, combo health, compression analytics, cost overview, health/autopilot, provider stats, route explainability, provider utilization, runtime. Adds shared `resolveProviderName` resolver and `useProviderNodeMap` hook. (#4603)
- **fix(dashboard):** on OAuth providers (e.g. GLM Coding), "Test all models" with auto-hide-failed now switches the model list to the "visible" filter after the run, so just-hidden failed models actually disappear on-screen — parity with the passthrough-provider path (#3610). Previously they were hidden in the DB but stayed visible under the "All" filter, so it looked like nothing was hidden. (#4887)
- **fix(pollinations):** stop forcing `jsonMode` on every request. Pollinations treats `jsonMode=true` as "the model MUST return JSON" and rejects (HTTP 400 "messages must contain the word 'json'") any normal chat request whose messages don't mention "json", so all non-JSON chat was broken. `jsonMode` is now only enabled when the caller actually requests JSON output (`response_format.type` of `json_object` or `json_schema`). (#3981)

---

Expand Down
8 changes: 7 additions & 1 deletion open-sse/executors/pollinations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ export class PollinationsExecutor extends BaseExecutor {
if (typeof body === "object" && body !== null) {
body.model = model;
body.stream = stream;
body.jsonMode = true;
// #3981: Pollinations treats jsonMode=true as "the model MUST return JSON"
// and rejects (HTTP 400) any request whose messages don't mention "json".
// Only enable it when the caller actually asked for JSON output.
const responseFormatType = body.response_format?.type;
if (responseFormatType === "json_object" || responseFormatType === "json_schema") {
body.jsonMode = true;
}
Comment on lines +44 to +47

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To ensure robustness against various client implementations (some of which might pass response_format as a string like "json_object" or "json", or as an object with a different structure), we should defensively check both string and object formats for response_format.

      const responseFormat = body.response_format;
      const isJsonRequested =
        responseFormat === "json_object" ||
        responseFormat === "json_schema" ||
        responseFormat === "json" ||
        responseFormat?.type === "json_object" ||
        responseFormat?.type === "json_schema" ||
        responseFormat?.type === "json";
      if (isJsonRequested) {
        body.jsonMode = true;
      }

}
return body;
}
Expand Down
38 changes: 38 additions & 0 deletions tests/unit/pollinations-jsonmode-3981.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import test from "node:test";
import assert from "node:assert/strict";

import { PollinationsExecutor } from "../../open-sse/executors/pollinations.ts";

// #3981: Pollinations rejects (HTTP 400 "messages must contain the word 'json'")
// any request with jsonMode=true whose messages don't mention "json". Setting
// jsonMode unconditionally broke every normal chat request. jsonMode must only
// be enabled when the caller actually requested JSON output.

test("#3981 transformRequest does NOT force jsonMode for a normal request", () => {
const executor = new PollinationsExecutor();
const body: any = {
messages: [{ role: "user", content: "Hello there" }],
};
const out = executor.transformRequest("openai", body, true, null);
assert.notEqual(out.jsonMode, true);
});

test("#3981 transformRequest enables jsonMode when response_format json_object is requested", () => {
const executor = new PollinationsExecutor();
const body: any = {
messages: [{ role: "user", content: "Return json" }],
response_format: { type: "json_object" },
};
const out = executor.transformRequest("openai", body, true, null);
assert.equal(out.jsonMode, true);
});

test("#3981 transformRequest enables jsonMode when response_format json_schema is requested", () => {
const executor = new PollinationsExecutor();
const body: any = {
messages: [{ role: "user", content: "Return structured json" }],
response_format: { type: "json_schema", json_schema: { name: "x", schema: {} } },
};
const out = executor.transformRequest("openai", body, true, null);
assert.equal(out.jsonMode, true);
});
Loading