Skip to content

fix: strip internal __meta from serialized request body - #18

Open
tazztone wants to merge 2 commits into
kargnas:mainfrom
tazztone:pr/strip-meta-request-body
Open

tazztone wants to merge 2 commits into
kargnas:mainfrom
tazztone:pr/strip-meta-request-body

Conversation

@tazztone

@tazztone tazztone commented Oct 27, 2026 •

Copy link
Copy Markdown

Problem

httpPost() attached its diagnostic metadata to the same object it later serialized:

lastPayload = payload;
lastPayload.__meta = { prompts };

Both transports then sent that object, so every request body carried a __meta property containing a second copy of the system and user prompts. OpenRouter's gateway does not reject unknown top-level fields, so this went unnoticed; strict OpenAI-compatible endpoints do. Groq returns:

{ "error": { "message": "property '__meta' is unsupported", "type": "invalid_request_error" } }

Fixes #17

Fix

  • lastPayload is now a shallow copy, so "Show Last Payload" keeps the prompts while the request payload stays clean.
  • lib/serialize.js adds toRequestBody(), which strips __meta before serialization. Both transports (fetch and curl) use it, so a future diagnostic field cannot leak back onto the wire.

Tests

npm test (node:test) covers:

  • __meta is stripped and the remaining fields are preserved verbatim
  • the caller payload is not mutated
  • payloads without __meta serialize unchanged
  • a tripwire fails if extension.js regains lastPayload.__meta = or JSON.stringify(payload), or loses either toRequestBody(payload) call site

Verification

  • npm ci && npm test → 5/5 pass
  • npx @vscode/vsce package → packages cleanly; lib/ included, test/ excluded
  • Extracted the real httpPost from the built extension and drove both transports against a local echo server: wire body keys are exactly model, messages, temperature, response_format, with no __meta, while "Show Last Payload" still renders __meta.prompts

No version bump: the release workflow handles that on merge.

Docs

Adds a Troubleshooting entry for HTTP 413 provider token-budget failures, with the settings that shrink the prompt.

httpPost() attached diagnostic metadata to the same object it later
serialized, so every request body carried a __meta property holding a
second copy of the system and user prompts. Strict OpenAI-compatible
providers reject unknown top-level properties (Groq: "property '__meta'
is unsupported").

- copy the payload before attaching __meta so Show Last Payload keeps working
- route fetch and curl bodies through toRequestBody(), which strips __meta
- add node:test coverage for the serializer and a tripwire against regressions

Fixes kargnas#17
Groq's on-demand tier caps input tokens per minute, so the default
context budget can be rejected even when the request body is valid.
Point users at the settings that shrink the prompt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom Groq endpoint rejects request because internal __meta is included in payload

1 participant