overleaf/overleaf · error · Error
Unknown mutable file tree action type: ${(action as Action).
Error message
Unknown mutable file tree action type: ${(action as Action).type} What it means
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.
Source
Thrown at services/web/frontend/js/shared/context/file-tree-data-context.tsx:154
fileCount: countFiles(newFileTreeData),
}
}
case ACTION_TYPES.CREATE: {
const newFileTreeData = createEntityInTree(
fileTreeData,
action.parentFolderId,
action.entity
)
return {
fileTreeData: newFileTreeData,
fileCount: countFiles(newFileTreeData),
}
}
default: {
throw new Error(
`Unknown mutable file tree action type: ${(action as Action).type}`
)
}
}
}
const initialState = (rootFolder?: Folder[]) => {
const fileTreeData = rootFolder?.[0]
return {
fileTreeData,
fileCount: countFiles(fileTreeData),
}
}
export function useFileTreeData() {
const context = useContext(FileTreeDataContext)
if (!context) {View on GitHub (pinned to 28ad3b03b7)
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
Example fix
// before
dispatch({ type: 'DELETE_FILE', ... })
// after
dispatch({ type: 'DELETE', ... }) Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_TYPES = ['createDoc','createFile','createFolder','rename','delete','move']
if (!KNOWN_TYPES.includes(action.type)) {
console.error('Unknown file-tree action', action)
return
}
dispatch(action) Type guard
function isFileTreeAction(a: { type: string }): a is Action {
return ['createDoc','createFile','createFolder','rename','delete','move'].includes(a.type)
} Try / catch
try {
dispatch(action)
} catch (e) {
if (String(e.message).startsWith('Unknown mutable file tree action type')) {
console.error('Bad action dispatched:', action);
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unknown subscription change preview type: ${preview.change}
- SubscriptionDashboardContext is only available inside Subscr
- DetachCompileProvider is only available inside LocalCompileP
- useDetachCompileContext is ony available inside DetachCompil
- useDetachContext is only available inside DetachProvider
AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03).
Data as JSON: /api/errors/79a328c4993f9e9f.
Report an issue: GitHub.