opencode
opencode copied to clipboard
TODO status 필드가 z.string()으로 정의되어 잘못된 상태값(예: 'build')이 허용됨
문제 설명
Plan 모드에서 TODO를 생성할 때, status 필드에 잘못된 값(예: "build")이 입력되어 문제가 발생합니다.
원인
packages/opencode/src/session/todo.ts에서 TODO의 status 필드가 z.string()으로 정의되어 있어 어떤 문자열이든 허용됩니다:
export const Info = z
.object({
content: z.string().describe("Brief description of the task"),
status: z.string().describe("Current status of the task: pending, in_progress, completed, cancelled"),
priority: z.string().describe("Priority level of the task: high, medium, low"),
id: z.string().describe("Unique identifier for the todo item"),
})
반면, UI 컴포넌트(packages/web/src/components/share/part.tsx)에서는 엄격한 타입을 사용합니다:
status: "pending" | "in_progress" | "completed"
이로 인해 AI 모델이 잘못된 상태값을 반환해도 검증되지 않습니다.
재현 방법
- Plan 모드에서 TODO 생성 요청
- AI가 잘못된 status 값(예: "build")을 반환하면 그대로 저장됨
제안하는 수정 방안
// packages/opencode/src/session/todo.ts
export const Info = z
.object({
content: z.string().describe("Brief description of the task"),
status: z.enum(["pending", "in_progress", "completed", "cancelled"])
.describe("Current status of the task"),
priority: z.enum(["high", "medium", "low"])
.describe("Priority level of the task"),
id: z.string().describe("Unique identifier for the todo item"),
})
환경
- OpenCode 버전: 1.0.162
- OS: macOS (darwin arm64)
This issue might be a duplicate of existing issues. Please check:
- #1354: AI_InvalidToolInputError: Invalid input for tool todowrite w/Gemini 2.5 Flash Lite Preview 06-17 - Shows AI models returning 'failed' as a status value when only valid enum values should be accepted
- #1373: AI_InvalidToolInputError: Invalid input for tool todowrite - General todowrite validation issues
- #520: Bug: OpenCode errors when cancelling a task - Related to missing status validation for 'cancelled' value
The root cause appears to be the same: the status field in the TODO schema is defined as z.string() instead of using z.enum() with strict validation, allowing AI models to return invalid status values.
Feel free to ignore if these don't match your specific case.