{"record":{"id":"ffe159c56e9f0a11","repo":"FlowiseAI/Flowise","slug":"error-chatflowscontroller-clearwebhooksecret-wo","errorCode":null,"errorMessage":"Error: chatflowsController.clearWebhookSecret - workspace not found!","messagePattern":"Error: chatflowsController\\.clearWebhookSecret - workspace not found!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":401,"severity":"error","filePath":"packages/server/src/controllers/chatflows/index.ts","lineNumber":331,"sourceCode":"        }\n        const apiResponse = await chatflowsService.setWebhookSecret(req.params.id, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst clearWebhookSecret = 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.clearWebhookSecret - id not provided!`\n            )\n        }\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(StatusCodes.UNAUTHORIZED, `Error: chatflowsController.clearWebhookSecret - workspace not found!`)\n        }\n        await chatflowsService.clearWebhookSecret(req.params.id, workspaceId)\n        return res.sendStatus(StatusCodes.NO_CONTENT)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst getScheduleStatus = 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.getScheduleStatus - id not provided!'\n            )\n        }\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/chatflows/index.ts#L313-L349","documentation":"Thrown by clearWebhookSecret when req.user?.activeWorkspaceId is falsy. Like setWebhookSecret it returns UNAUTHORIZED (401) rather than the NOT_FOUND used elsewhere — a deliberate or accidental status-code divergence. The operation is workspace-scoped and cannot run without that context.","triggerScenarios":"Unauthenticated request, expired session, or an authenticated user whose activeWorkspaceId is not set. Same root cause family as the other workspace guards but flagged as 401.","commonSituations":"Token expiry between page load and the action, a 401-gated flow that did not re-auth, or test code that omits req.user.","solutions":["Re-authenticate and resend with a valid session/API key.","Ensure the user has an active workspace before attempting to clear the secret.","Mirror the auth middleware used by sibling chatflow routes."],"exampleFix":"// before\nawait fetch(`/api/v1/chatflows/${id}/webhook-secret`, { method: 'DELETE' })\n// after\nawait fetch(`/api/v1/chatflows/${id}/webhook-secret`, {\n  method: 'DELETE',\n  headers: { Cookie: sessionCookie }\n})","handlingStrategy":"validation","validationCode":"async function authedDelete(url: string) {\n  if (!token) throw new Error('no auth token - cannot resolve active workspace')\n  return fetch(url, { method: 'DELETE', headers: { Authorization: `Bearer ${token}` } })\n}","typeGuard":"const hasActiveWorkspace = (u: unknown): u is { activeWorkspaceId: string } =>\n  !!u && typeof (u as any).activeWorkspaceId === 'string'","tryCatchPattern":"try { await api.clearWebhookSecret(id) } catch (e) { if (e.statusCode === 401) { await reAuth(); await api.clearWebhookSecret(id) } else throw e }","preventionTips":["Re-authenticate on 401 before retrying.","Ensure the user has an active workspace.","Verify auth middleware on the route."],"tags":["flowise","controller","validation","workspace","auth","unauthorized","webhook","typescript"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}