Add graceful fallback for missing response.id from NVIDIA NIM #3931

Closed
opened 2026-02-16 17:41:59 -05:00 by yindo · 2 comments
Owner

Originally created by @chindris-mihai-alexandru on GitHub (Dec 28, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description
OpenCode crashes with AI_InvalidResponseDataError: Expected "id" to be a string when the NVIDIA NIM endpoint returns a tool‑call response without an id field.

Reproduction steps

  1. Obtain a valid NVIDIA_NIM_KEY.
  2. Run the curl command from the NVIDIA issue (see that issue for the exact command).
  3. The raw JSON response from NIM does not contain an id property.
  4. OpenCode validates the payload and throws the error.

Expected behaviour
If the id field is missing or not a string, the integration should automatically generate a temporary UUID (e.g., msg_<uuid>) and continue processing instead of aborting.

Suggested implementation

function normalizeMistralResponse(resp: any): any {
  if (!resp.id || typeof resp.id !== "string") {
    resp.id = `msg_${crypto.randomUUID()}`;
  }
  return resp;
}

Add this guard before any SDK validation that expects id.

Impact
All users who call any NVIDIA NIM model from OpenCode will stop crashing.

Environment

Originally created by @chindris-mihai-alexandru on GitHub (Dec 28, 2025). Originally assigned to: @rekram1-node on GitHub. **Description** OpenCode crashes with `AI_InvalidResponseDataError: Expected "id" to be a string` when the NVIDIA NIM endpoint returns a tool‑call response without an `id` field. **Reproduction steps** 1. Obtain a valid `NVIDIA_NIM_KEY`. 2. Run the curl command from the NVIDIA issue (see that issue for the exact command). 3. The raw JSON response from NIM does **not** contain an `id` property. 4. OpenCode validates the payload and throws the error. **Expected behaviour** If the `id` field is missing or not a string, the integration should automatically generate a temporary UUID (e.g., `msg_<uuid>`) and continue processing instead of aborting. **Suggested implementation** ```ts function normalizeMistralResponse(resp: any): any { if (!resp.id || typeof resp.id !== "string") { resp.id = `msg_${crypto.randomUUID()}`; } return resp; } ``` Add this guard before any SDK validation that expects `id`. **Impact** All users who call any NVIDIA NIM model from OpenCode will stop crashing. **Environment** - OpenCode version: 1.0.191 - NVIDIA NIM endpoint: https://integrate.api.nvidia.com/v1/chat/completions - Model: Devstral-2-123B-Instruct-2512 - Date: 2025‑12‑28
yindo closed this issue 2026-02-16 17:41:59 -05:00
Author
Owner

@chindris-mihai-alexandru commented on GitHub (Dec 28, 2025):

Related NVIDIA issue: https://github.com/NVIDIA/nim-deploy/issues/182

@chindris-mihai-alexandru commented on GitHub (Dec 28, 2025): Related NVIDIA issue: https://github.com/NVIDIA/nim-deploy/issues/182
Author
Owner

@stromseng commented on GitHub (Jan 16, 2026):

Related similar GLM 4.7 and others issue: https://github.com/anomalyco/opencode/issues/1880

@stromseng commented on GitHub (Jan 16, 2026): Related similar GLM 4.7 and others issue: https://github.com/anomalyco/opencode/issues/1880
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3931