{"record":{"id":"50e1cec037f8c77e","repo":"eyaltoledano/claude-task-master","slug":"warn-error-updating-state-for-migration-notice","errorCode":null,"errorMessage":"[WARN] Error updating state for migration notice: ${stateError.message}","messagePattern":"\\[WARN\\] Error updating state for migration notice: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"scripts/modules/utils.js","lineNumber":964,"sourceCode":"\t\tconst statePath = path.join(projectRoot, '.taskmaster', 'state.json');\n\n\t\t// Ensure state.json exists\n\t\tif (!fs.existsSync(statePath)) {\n\t\t\tcreateStateJson(statePath);\n\t\t}\n\n\t\t// Read and update state to mark migration occurred using fs directly\n\t\ttry {\n\t\t\tconst rawState = fs.readFileSync(statePath, 'utf8');\n\t\t\tconst stateData = JSON.parse(rawState) || {};\n\t\t\t// Only set to false if it's not already set (i.e., first time migration)\n\t\t\tif (stateData.migrationNoticeShown === undefined) {\n\t\t\t\tstateData.migrationNoticeShown = false;\n\t\t\t\tfs.writeFileSync(statePath, JSON.stringify(stateData, null, 2), 'utf8');\n\t\t\t}\n\t\t} catch (stateError) {\n\t\t\tif (process.env.TASKMASTER_DEBUG === 'true') {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[WARN] Error updating state for migration notice: ${stateError.message}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tif (process.env.TASKMASTER_DEBUG === 'true') {\n\t\t\tconsole.warn(\n\t\t\t\t`[WARN] Error marking migration for notice: ${error.message}`\n\t\t\t);\n\t\t}\n\t}\n}\n\n// Shared FileOperations instance for modifyJSON\nlet _fileOps = null;\n\n/**\n * Gets or creates the shared FileOperations instance","sourceCodeStart":946,"sourceCodeEnd":982,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/utils.js#L946-L982","documentation":"markMigrationForNotice tries to read the state file and initialize migrationNoticeShown; if writing/updating that state file fails (stateError) the message is only printed when TASKMASTER_DEBUG=true. It indicates the .taskmaster/state.json could not be read or written, but the failure is swallowed by design so migrations don't break main flows.","triggerScenarios":"Any call path through markMigrationForNotice (addTask, readJSON) where fs.writeFileSync on the state file throws: read-only filesystem, missing .taskmaster directory, permission errors, malformed existing state.json causing JSON.parse to throw, or disk-full.","commonSituations":"Running in containers/CI with read-only mounts; state.json hand-edited into invalid JSON; ownership/permission issues after sudo usage; TASKMASTER_DEBUG enabled while the directory was deleted mid-run.","solutions":["Fix filesystem permissions on .taskmaster/state.json (chown/chmod) so the process can write.","Validate and repair state.json — it must be valid JSON; delete or fix a corrupted file.","Create the .taskmaster directory if it is missing.","If you need visibility, keep TASKMASTER_DEBUG=true and read the warning; otherwise it is safely ignorable.","Check disk space / mount read-only flags in the execution environment."],"exampleFix":"// before\n// .taskmaster/state.json contains a trailing comma -> JSON.parse throws\n// after\n{ \"migrationNoticeShown\": false }  // valid JSON, write succeeds","handlingStrategy":"try-catch","validationCode":"const statePath = path.join(projectRoot, '.taskmaster', 'state.json');\nif (!fs.existsSync(path.dirname(statePath))) fs.mkdirSync(path.dirname(statePath), { recursive: true });\nlet stateData = {};\ntry { stateData = JSON.parse(fs.readFileSync(statePath, 'utf8')); }\ncatch { stateData = {}; }","typeGuard":null,"tryCatchPattern":"try {\n  markMigrationForNotice(projectRoot);\n} catch (e) {\n  if (process.env.TASKMASTER_DEBUG === 'true') {\n    console.warn(`[WARN] migration notice state update failed: ${e.message}`);\n  }\n  // non-fatal: continue\n}","preventionTips":["Keep .taskmaster writable by the running user.","Never hand-edit state.json without validating JSON afterwards.","Set TASKMASTER_DEBUG=true when diagnosing state issues.","Check disk space and mount flags in containers/CI."],"tags":["filesystem","state","debug"],"backgroundTag":"state-file-write-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}