Skip to content

fix: guard detectPlanningLoop against non-array messages input#108

Merged
dzianisv merged 1 commit intomainfrom
fix/detect-planning-loop-array-guard
Feb 15, 2026
Merged

fix: guard detectPlanningLoop against non-array messages input#108
dzianisv merged 1 commit intomainfrom
fix/detect-planning-loop-array-guard

Conversation

@dzianisv
Copy link
Owner

Summary

  • Adds Array.isArray(messages) guard at the top of detectPlanningLoop to prevent TypeError: {} is not iterable when the OpenCode framework passes {} instead of an array
  • This was the root cause of 500 errors on every HTTP request to the server, blocking E2E test suites

Context

PR #106 added guards at the 4 client.session.messages() call sites, but detectPlanningLoop itself could still receive non-array input from the plugin framework's internal call path (src/plugin/index.ts:90).

The OpenCode plugin framework can pass {} instead of an array to
detectPlanningLoop via the session event handler, causing TypeError:
'{} is not iterable'. This made every HTTP request to the server
return 500, blocking E2E test suites.

Add Array.isArray guard at the top of detectPlanningLoop itself,
matching the existing pattern in buildTaskContext.
@dzianisv dzianisv merged commit 9ed9d08 into main Feb 15, 2026
2 checks passed
@dzianisv dzianisv deleted the fix/detect-planning-loop-array-guard branch February 15, 2026 08:47
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.

1 participant