{"record":{"id":"79a328c4993f9e9f","repo":"overleaf/overleaf","slug":"unknown-mutable-file-tree-action-type-action-a","errorCode":null,"errorMessage":"Unknown mutable file tree action type: ${(action as Action).type}","messagePattern":"Unknown mutable file tree action type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"services/web/frontend/js/shared/context/file-tree-data-context.tsx","lineNumber":154,"sourceCode":"        fileCount: countFiles(newFileTreeData),\n      }\n    }\n\n    case ACTION_TYPES.CREATE: {\n      const newFileTreeData = createEntityInTree(\n        fileTreeData,\n        action.parentFolderId,\n        action.entity\n      )\n\n      return {\n        fileTreeData: newFileTreeData,\n        fileCount: countFiles(newFileTreeData),\n      }\n    }\n\n    default: {\n      throw new Error(\n        `Unknown mutable file tree action type: ${(action as Action).type}`\n      )\n    }\n  }\n}\n\nconst initialState = (rootFolder?: Folder[]) => {\n  const fileTreeData = rootFolder?.[0]\n  return {\n    fileTreeData,\n    fileCount: countFiles(fileTreeData),\n  }\n}\n\nexport function useFileTreeData() {\n  const context = useContext(FileTreeDataContext)\n\n  if (!context) {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/overleaf/overleaf/blob/28ad3b03b71cb4311decdcb55c36b33ec10d72db/services/web/frontend/js/shared/context/file-tree-data-context.tsx#L136-L172","documentation":"fileTreeMutableReducer is a React reducer handling mutable file-tree operations (create, rename, delete, move). When it receives an action whose .type it does not recognize, it throws this error from the default branch. Because reducers run during dispatch/render, this aborts the component update.","triggerScenarios":"Dispatching an action to the mutable file-tree reducer with a mistyped or misspelled action type string; dispatching an action object intended for a different (immutable) file-tree reducer; a version mismatch where new action types are dispatched against an older reducer.","commonSituations":"Renaming an action type in one file but not the dispatch site; copy-pasting dispatch calls between the mutable and derived file-tree reducers; a custom feature dispatching its own action into the file-tree reducer by mistake.","solutions":["Log the dispatched action object to inspect its type value","Correct the action type to one supported by the mutable reducer (createDoc/createFile/createFolder/rename/delete/move)","Verify you are dispatching to the correct reducer (mutable vs derived file tree)","Add a TypeScript discriminated union on Action so invalid types fail at compile time"],"exampleFix":"// before\ndispatch({ type: 'DELETE_FILE', ... })\n// after\ndispatch({ type: 'DELETE', ... })","handlingStrategy":"validation","validationCode":"const KNOWN_TYPES = ['createDoc','createFile','createFolder','rename','delete','move']\nif (!KNOWN_TYPES.includes(action.type)) {\n  console.error('Unknown file-tree action', action)\n  return\n}\ndispatch(action)","typeGuard":"function isFileTreeAction(a: { type: string }): a is Action {\n  return ['createDoc','createFile','createFolder','rename','delete','move'].includes(a.type)\n}","tryCatchPattern":"try {\n  dispatch(action)\n} catch (e) {\n  if (String(e.message).startsWith('Unknown mutable file tree action type')) {\n    console.error('Bad action dispatched:', action);\n  }\n}","preventionTips":["Define Action as a TypeScript discriminated union so bad types fail at compile time","Share one Action type definition between dispatch sites and the reducer","Name action types consistently to avoid cross-reducer confusion","Add a unit test that exercises every action type"],"tags":["react","reducer","file-tree"],"backgroundTag":"unknown-action-type","analyzedSha":"28ad3b03b71cb4311decdcb55c36b33ec10d72db","analyzedAt":"2026-09-03T02:10:22.807Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}