{"record":{"id":"9c6c3cd01bdae01d","repo":"vxcontrol/pentagi","slug":"operation-d-reorder-requires-id","errorCode":null,"errorMessage":"operation %d: reorder requires id","messagePattern":"operation (.+?): reorder requires id","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/args.go","lineNumber":341,"sourceCode":"\t\t\t\treturn fmt.Errorf(\"operation %d: add requires title\", i)\n\t\t\t}\n\t\t\tif op.Description == \"\" {\n\t\t\t\treturn fmt.Errorf(\"operation %d: add requires description\", i)\n\t\t\t}\n\t\tcase SubtaskOpRemove:\n\t\t\tif op.ID == nil {\n\t\t\t\treturn fmt.Errorf(\"operation %d: remove requires id\", i)\n\t\t\t}\n\t\tcase SubtaskOpModify:\n\t\t\tif op.ID == nil {\n\t\t\t\treturn fmt.Errorf(\"operation %d: modify requires id\", i)\n\t\t\t}\n\t\t\tif op.Title == \"\" && op.Description == \"\" {\n\t\t\t\treturn fmt.Errorf(\"operation %d: modify requires at least title or description\", i)\n\t\t\t}\n\t\tcase SubtaskOpReorder:\n\t\t\tif op.ID == nil {\n\t\t\t\treturn fmt.Errorf(\"operation %d: reorder requires id\", i)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"operation %d: unknown operation type %q\", i, op.Op)\n\t\t}\n\t}\n\treturn nil\n}\n\ntype Bool bool\n\nfunc (b *Bool) UnmarshalJSON(data []byte) error {\n\tsdata := strings.Trim(strings.ToLower(string(data)), \"' \\\"\\n\\r\\t\")\n\tswitch sdata {\n\tcase \"true\":\n\t\t*b = true\n\tcase \"false\":\n\t\t*b = false\n\tdefault:","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/args.go#L323-L359","documentation":"SubtaskPatch.Validate requires a non-nil ID for SubtaskOpReorder; this error fires when a reorder operation omits the ID of the subtask to move. Without it the position change cannot be attributed to a subtask.","triggerScenarios":"Patch operation {\"op\":\"reorder\"} without \"id\" (position fields only), submitted through patch_flow_subtasks or SubtaskPatch.Validate.","commonSituations":"LLM tries to reorder 'the second subtask' by index without resolving its ID; batch reorder scripts that emit only positions.","solutions":["Resolve each subtask ID via get_flow_status detail=subtasks and set it on each reorder op.","Pre-validate ops and skip/fix reorder entries with nil ID.","Update tool schema descriptions/prompt to stress the required id for reorder."],"exampleFix":"// before\nops := []SubtaskOperation{{Op: SubtaskOpReorder, Position: int64Ptr(1)}}\n// after\nops := []SubtaskOperation{{Op: SubtaskOpReorder, ID: int64Ptr(12), Position: int64Ptr(1)}}","handlingStrategy":"type-guard","validationCode":"for i, op := range ops {\n    if op.Op == \"reorder\" && op.ID == nil {\n        return fmt.Errorf(\"op %d: reorder needs id\", i)\n    }\n}","typeGuard":"func reorderableOp(op SubtaskOperation) bool {\n    return op.Op == SubtaskOpReorder && op.ID != nil\n}","tryCatchPattern":"if err := patch.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"reorder requires id\") {\n        // fetch plan, resolve IDs, rebuild reorder ops with explicit IDs\n    }\n}","preventionTips":["Resolve subtask IDs before emitting reorder operations.","Never specify reorders by index alone in generated patches.","Pre-validate reorder ops for non-nil ID before applying.","Document the required id field in the reorder tool schema description."],"tags":["validation","tool-args","subtasks"],"backgroundTag":"missing-required-argument","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}