{"record":{"id":"3afdfa3d13f94a0a","repo":"FlowiseAI/Flowise","slug":"error-credentialscontroller-getallcredentials-w","errorCode":null,"errorMessage":"Error: credentialsController.getAllCredentials - workspace ${workspaceId} not found!","messagePattern":"Error: credentialsController\\.getAllCredentials - workspace (.+?) not found!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":404,"severity":"error","filePath":"packages/server/src/controllers/credentials/index.ts","lineNumber":49,"sourceCode":"        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: credentialsController.deleteCredentials - workspace ${workspaceId} not found!`\n            )\n        }\n        const apiResponse = await credentialsService.deleteCredentials(req.params.id, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst getAllCredentials = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: credentialsController.getAllCredentials - workspace ${workspaceId} not found!`\n            )\n        }\n        const apiResponse = await credentialsService.getAllCredentials(req.query.credentialName, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst getCredentialById = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (typeof req.params === 'undefined' || !req.params.id) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: credentialsController.getCredentialById - id not provided!`\n            )","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/credentials/index.ts#L31-L67","documentation":"Thrown by getAllCredentials when the authenticated user's activeWorkspaceId is missing from req.user. Identical root cause to the delete/workspace errors elsewhere in this controller — the GET-all path checks only workspaceId and nothing else, so the very first request a user makes after a broken login will trip this. The message interpolates the unresolved ${workspaceId} (literally 'undefined').","triggerScenarios":"GET /api/v1/credentials?credentialName=... issued with a JWT/session that lacks activeWorkspaceId. Common on first page-load after login when the credentials list is fetched immediately. Also fires when an API client reuses a token issued under a different platform mode.","commonSituations":"Frontend loads the Credentials page before the user has selected or been assigned a workspace. Token was issued for an org-only context. Cookie was cleared but stale SSR/cached token reused. Dev environment with PORTAL=true but no workspace seeded.","solutions":["Re-authenticate the user (sign out → sign in) so a fresh JWT carrying activeWorkspaceId is issued.","Ensure the user is a member of at least one workspace; assign membership if missing.","On the client, gate the credentials list fetch behind an activeWorkspaceId being present in the logged-in user payload.","In tests, stub req.user with a non-empty activeWorkspaceId.","Verify the login strategy (passport localStrategy in passport/index.ts) populates activeWorkspaceId from workspaceUser.workspaceId before calling done()."],"exampleFix":"// client-side guard before calling getAllCredentials\nif (!loggedInUser.activeWorkspaceId) {\n  await switchWorkspace(defaultWorkspaceId)\n}\nconst creds = await api.getAllCredentials()","handlingStrategy":"validation","validationCode":"// client guard before the credentials list fetch\nfunction hasWorkspaceClaim(u): u is { activeWorkspaceId: string } {\n  return !!u && typeof u.activeWorkspaceId === 'string' && u.activeWorkspaceId.length > 0\n}\n\nif (hasWorkspaceClaim(loggedInUser)) {\n  const creds = await api.getAllCredentials()\n} else {\n  // prompt workspace selection or redirect to login\n}","typeGuard":"function hasWorkspaceClaim(u: unknown): u is { activeWorkspaceId: string } {\n  return typeof u === 'object' && u !== null\n    && typeof (u as any).activeWorkspaceId === 'string'\n    && (u as any).activeWorkspaceId.length > 0\n}","tryCatchPattern":"try {\n  return await api.getAllCredentials()\n} catch (e) {\n  if (e.status === 404 && /workspace .* not found/.test(e.message)) {\n    return await reauthenticateThenRetry(() => api.getAllCredentials())\n  }\n  throw e\n}","preventionTips":["Gate any workspace-scoped API call behind a truthy activeWorkspaceId check on the client.","Surface a 'select workspace' screen when activeWorkspaceId is missing instead of letting API calls fail.","Re-mint the token whenever the user's workspace set changes."],"tags":["auth","session","workspace","credentials","flowise"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}