{"record":{"id":"a1216d04b9a20350","repo":"FlowiseAI/Flowise","slug":"error-chatflowscontroller-togglescheduleenabled","errorCode":null,"errorMessage":"Error: chatflowsController.toggleScheduleEnabled - id not provided!","messagePattern":"Error: chatflowsController\\.toggleScheduleEnabled - id not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"error","filePath":"packages/server/src/controllers/chatflows/index.ts","lineNumber":419,"sourceCode":"                StatusCodes.NOT_FOUND,\n                'Error: chatflowsController.deleteScheduleTriggerLogs - workspace not found!'\n            )\n        }\n        const logIds: unknown = req.body?.logIds\n        if (!Array.isArray(logIds) || logIds.some((x) => typeof x !== 'string')) {\n            throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'logIds must be a string[]')\n        }\n        const result = await scheduleService.deleteTriggerLogs(req.params.id, workspaceId, logIds as string[])\n        return res.json(result)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst toggleScheduleEnabled = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (!req.params?.id) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                'Error: chatflowsController.toggleScheduleEnabled - id not provided!'\n            )\n        }\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(StatusCodes.NOT_FOUND, 'Error: chatflowsController.toggleScheduleEnabled - workspace not found!')\n        }\n        const { enabled } = req.body\n        if (typeof enabled !== 'boolean') {\n            throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, '\"enabled\" must be a boolean')\n        }\n        const record = await scheduleService.toggleScheduleEnabled(req.params.id, workspaceId, enabled)\n        await ScheduleBeat.getInstance().onScheduleChanged(record.id, enabled ? 'upsert' : 'delete')\n        return res.json(record)\n    } catch (error) {\n        next(error)\n    }","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/chatflows/index.ts#L401-L437","documentation":"Thrown by toggleScheduleEnabled when req.params?.id is falsy. The endpoint turns a chatflow's scheduled trigger on/off, so it must target a specific chatflow. Returned as PRECONDITION_FAILED (412). After validation it reads req.body.enabled and notifies ScheduleBeat.","triggerScenarios":"POST/PUT to the toggle route with the :id segment missing.","commonSituations":"Toggle button clicked before a chatflow is loaded, URL built from an undefined id, or route not declaring :id.","solutions":["Provide the chatflow id in the path.","Disable the toggle control on the client until a chatflow is selected.","Confirm the route declares :id."],"exampleFix":"// before\nfetch(`/api/v1/chatflows//schedule/toggle`, { method: 'POST', body: JSON.stringify({ enabled: true }) })\n// after\nfetch(`/api/v1/chatflows/${encodeURIComponent(id)}/schedule/toggle`, { method: 'POST', body: JSON.stringify({ enabled: true }) })","handlingStrategy":"validation","validationCode":"function toggleSchedule(id: string, enabled: boolean) {\n  if (!id) throw new Error('chatflow id required to toggle schedule')\n  return fetch(`/api/v1/chatflows/${encodeURIComponent(id)}/schedule/toggle`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ enabled }) })\n}","typeGuard":"const isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0","tryCatchPattern":"try { await toggleSchedule(id, true) } catch (e) { if (e.statusCode === 412) throw new Error('provide a chatflow id') }","preventionTips":["Enable the toggle only when a chatflow is selected.","Validate id presence client-side.","Confirm the route declares :id."],"tags":["flowise","controller","validation","precondition-failed","path-param","scheduling","typescript"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}