{"record":{"id":"edd0897c2eebb324","repo":"jackwener/OpenCLI","slug":"slock-task-status-returned-status-taskstatus-e","errorCode":null,"errorMessage":"Slock task-status returned status ${taskStatus}, expected ${expectedStatus}.","messagePattern":"Slock task-status returned status (.+?), expected (.+?)\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/slock/task-status.js","lineNumber":90,"sourceCode":"      };\n    });\n  },\n});\n\nfunction assertTaskMutationIdentity(t, expectedId, expectedStatus) {\n  const taskId = t?.id;\n  if (!taskId) {\n    throw new CommandExecutionError(`Slock task-status succeeded without returning task id ${expectedId}; refusing to report a status row.`);\n  }\n  if (taskId !== expectedId) {\n    throw new CommandExecutionError(`Slock task-status returned task id ${taskId}, expected ${expectedId}.`);\n  }\n  const taskStatus = t.taskStatus ?? t.status;\n  if (!taskStatus) {\n    throw new CommandExecutionError(`Slock task-status returned task ${expectedId} without taskStatus.`);\n  }\n  if (taskStatus !== expectedStatus) {\n    throw new CommandExecutionError(`Slock task-status returned status ${taskStatus}, expected ${expectedStatus}.`);\n  }\n  return { taskId, taskStatus };\n}\n","sourceCodeStart":72,"sourceCodeEnd":94,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/task-status.js#L72-L94","documentation":"assertTaskMutationIdentity final check: the status returned for the task must equal the status the command expected (the status the mutation was supposed to produce). This throw fires when the task was found with the right id but its status differs, meaning the mutation did not take effect as expected and the CLI refuses to fabricate a success row.","triggerScenarios":"Requesting a status transition (e.g. expecting `done`) but the API returns the task still in `in_progress` — concurrent updates, optimistic-lock rejection rendered as success, eventual consistency on replicas, or the wrong expected status passed to the command.","commonSituations":"Another agent/user moved the task between your call and the read; hitting a read-replica that lags the write; passing a hardcoded expected status that no longer matches workflow state; terminal-status tasks rejecting further transitions.","solutions":["Re-run the command — transient replication lag often resolves on retry.","Print the actual status from the error message and update your expected status/automation accordingly.","Check for concurrent writers (other agents, web UI sessions) mutating the same task.","Verify the mutation endpoint actually succeeded (check HTTP status in the snippet) before assuming a status transition."],"exampleFix":"// before\nawait cli.run(['task-status', id, '--expected-status', 'done']);\n// after: poll until the expected status appears\nfor (let i = 0; i < 5; i++) {\n  try { await cli.run(['task-status', id, '--expected-status', 'done']); break; }\n  catch (e) { if (i === 4) throw e; await sleep(500); }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for (let attempt = 0; attempt < 3; attempt++) {\n  try { await cli.run(['task-status', id, '--expected-status', want]); break; }\n  catch (e) {\n    if (String(e.message).includes('returned status') && attempt < 2) await sleep(500);\n    else throw e;\n  }\n}","preventionTips":["Retry on status mismatches to absorb replication lag","Avoid concurrent writers to the same task","Derive expected status from the workflow, not hardcoded values"],"tags":["state-mismatch","concurrency","task-status"],"backgroundTag":"expected-state-mismatch","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}