GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Missing array bounds checking in LLM provider response handling · Issue #11700 · anomalyco/opencode Closed DescriptionSummaryThe LLM provider SDK code accesses array elements without checking if the array is non-empty, which can cause runtime crashes when the API returns unexpected responses. Locations
Issue// Line 216 - doGenerate() const choice = responseBody.choices[0] // No check if choices array is empty const content: Array<LanguageModelV2Content> = [] const text = choice.message.content // Will throw if choice is undefined // Line 435 - doStream() const choice = value.choices[0] // Same issue in streaming if (choice?.finish_reason != null) { // ... } If the API returns an empty Impact
Suggested FixAdd bounds checking: const choice = responseBody.choices[0] if (!choice) { throw new InvalidResponseDataError({ data: responseBody, message: "Response contained no choices" }) } Or use optional chaining with fallback: const choice = responseBody.choices?.[0] if (!choice?.message) { // Handle empty response case } Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |