fix: recover lost files from worflow-ui branch#46
Conversation
📝 WalkthroughWalkthroughThree files were modified to enhance workflow and credential management. Backend route handlers were refactored with explicit try-catch error handling and two new GET endpoints added for credential retrieval and empty workflow fetching. Frontend components were updated to improve node-click handling and workflow initialization. A new configuration library module was created with API wrappers for credentials, workflows, triggers, and nodes. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (6)
apps/web/app/components/nodes/CreateWorkFlow.tsx (2)
300-324: Remove console.log statements and improve type checking.Multiple console.log statements should be removed before production. Additionally, the string matching logic for Google Sheet detection (lines 313) uses case-insensitive matching but relies on string inclusion which could yield false positives.
🔎 Proposed refactor
onNodeClick={async(event, node) => { - console.log("Node clicked:", node.id, node.type, node.data); if (node.type === "placeholder") { const hasTrigger = nodes.some((n) => n.type === "trigger"); if (hasTrigger) { setActionSidebarOpen(true); } else { setSidebarOpen(true); } } if(node.type === 'action' || node.type === 'trigger'){ - // Check by type instead of name (more reliable) const nodeType = node.data.type?.toLowerCase() || ''; - if(nodeType.includes('google_sheet') || nodeType.includes('google sheet')){ - console.log("Google Sheet node clicked") - console.log("Node ID:", node.id) + // Use exact match or enum-based comparison instead of substring matching + if(nodeType === 'google_sheet' || nodeType === 'google_sheets'){ setNodeIDType(node.id) setCredType("google_oauth") - console.log("config from node: ", node.data.config) setSelectedNodeConfig(node.data.config) setLoadSheet(!loadSheet) - console.log("Form opened") } } }}
339-352: Add validation before accessing configuration properties.Type assertions (
as string) on lines 345-349 assume the config structure without validation. IfselectedNodeConfighas a different shape, this could cause runtime errors.🔎 Proposed refactor
{loadSheet && <GoogleSheetFormClient type={credType} nodeType={nodeIDType} position={existingNodes.length + 1} - initialData={selectedNodeConfig ? { - range: selectedNodeConfig.range as string, - operation: selectedNodeConfig.operation as string, - sheetName: selectedNodeConfig.sheetName as string, - spreadSheetId: selectedNodeConfig.spreadsheetId as string, - credentialId: selectedNodeConfig.credId as string, - } : undefined} + initialData={selectedNodeConfig && + typeof selectedNodeConfig.range === 'string' && + typeof selectedNodeConfig.operation === 'string' && + typeof selectedNodeConfig.sheetName === 'string' && + typeof selectedNodeConfig.spreadsheetId === 'string' && + typeof selectedNodeConfig.credId === 'string' ? { + range: selectedNodeConfig.range, + operation: selectedNodeConfig.operation, + sheetName: selectedNodeConfig.sheetName, + spreadSheetId: selectedNodeConfig.spreadsheetId, + credentialId: selectedNodeConfig.credId, + } : undefined} /> }apps/http-backend/src/routes/userRoutes/userRoutes.ts (2)
71-71: Consider consistent route declaration formatting.Route declarations have inconsistent formatting—some have the path string on the same line as
router.get/post, others on the next line. While not critical, consistent formatting improves readability.Also applies to: 96-96, 130-130, 230-230, 282-282, 338-338
158-158: Add explicit type annotation for consistency.The
resparameter should be explicitly typed asResponsefor consistency with other route handlers in this file (lines 40, 73, 98, 132, 203, etc.).🔎 Proposed fix
-async (req: AuthRequest, res) =>{ +async (req: AuthRequest, res: Response) =>{apps/web/app/workflow/lib/config.ts (2)
78-100: Remove console.log statement.Line 94 contains a console.log that should be removed for production code.
🔎 Proposed refactor
const workflow = response.data - console.log('new workflow: ',workflow) return workflow.Data
102-144: Remove console.log statements.Lines 117 and 132 contain console.log statements that should be removed for production code.
🔎 Proposed refactor
export const createTrigger = async(context: Triggercontext)=>{ try{ - console.log('Trigger context: ', context) const response = await axios.post(`${BACKEND_URL}/user/create/trigger`, { Name: context.name, AvailableTriggerID: context.node_Trigger, Config: context.config, WorkflowId: context.workflowId, TriggerType:"" }, { headers: {"Content-Type": "application/json"}, withCredentials:true }) const trigger = (response.data) - console.log('trigger created: ', trigger); return { success: true, data: trigger }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/http-backend/src/routes/userRoutes/userRoutes.tsapps/web/app/components/nodes/CreateWorkFlow.tsxapps/web/app/workflow/lib/config.ts
🧰 Additional context used
🧬 Code graph analysis (2)
apps/web/app/workflow/lib/config.ts (2)
packages/nodes/src/common/google-oauth-service.ts (2)
getCredentials(77-101)getAllCredentials(103-117)packages/common/src/index.ts (1)
BACKEND_URL(4-4)
apps/http-backend/src/routes/userRoutes/userRoutes.ts (2)
apps/http-backend/src/routes/userRoutes/userMiddleware.ts (2)
AuthRequest(8-10)userMiddleware(18-42)packages/db/src/index.ts (1)
prismaClient(17-18)
| router.get('/getCredentials/:type', | ||
| userMiddleware, | ||
| async (req: AuthRequest, res) => { | ||
| try { | ||
| console.log("user from getcredentials: ", req.user); | ||
| if (!req.user) { | ||
| return res.status(statusCodes.BAD_REQUEST).json({ | ||
| message: "User is not Loggedin", | ||
| }); | ||
| } | ||
| const userId = req.user.sub; | ||
| const type = req.params.type; | ||
| console.log(userId, " -userid"); | ||
| if (!type || !userId) { | ||
| return res.status(statusCodes.BAD_REQUEST).json({ | ||
| message: "Incorrect type Input", | ||
| }); | ||
| } | ||
| const executor = new GoogleSheetsNodeExecutor(); | ||
| const response = await executor.getAllCredentials(userId, type); | ||
| // console.log( typeof(response)); | ||
| // console.log("response: ",response) | ||
| const authUrl = typeof response === "string" ? response : null; | ||
| // console.log(authUrl); | ||
|
|
||
| const credentials = response instanceof Object ? response : null; | ||
| // console.log(credentials) | ||
| if (authUrl) { | ||
| return res.status(statusCodes.OK).json({ | ||
| message: | ||
| "Credentials not found create credentials using this auth url", | ||
| async (req: AuthRequest, res) =>{ | ||
| try{ | ||
| console.log("user from getcredentials: ",req.user) | ||
| if(!req.user){ | ||
| return res.status(statusCodes.BAD_REQUEST).json({ | ||
| message: "User is not Loggedin" | ||
| }) | ||
| } | ||
| const userId = req.user.sub; | ||
| const type = req.params.type | ||
| console.log(userId," -userid") | ||
| if(!type || !userId){ | ||
| return res.status(statusCodes.BAD_REQUEST).json({ | ||
| message: "Incorrect type Input", | ||
| }); | ||
| } | ||
| const executor = new GoogleSheetsNodeExecutor() | ||
| const response = await executor.getAllCredentials(userId,type) | ||
| // console.log( typeof(response)); | ||
| // console.log("response: ",response) | ||
| const authUrl = typeof response === 'string' ? response : null | ||
| // console.log(authUrl); | ||
|
|
||
| const credentials = response instanceof Object ? response : null | ||
| // console.log(credentials) | ||
| if(authUrl){ | ||
| return res.status(statusCodes.OK).json({ | ||
| message: "Credentials not found create credentials using this auth url", | ||
| Data: authUrl, | ||
| }); | ||
| } else | ||
| return res.status(statusCodes.OK).json({ | ||
| } | ||
| else return res.status(statusCodes.OK).json({ | ||
| message: "Credentials Fetched succesfully", | ||
| Data: credentials, | ||
| }); | ||
| } catch (e) { | ||
| console.log( | ||
| "Error Fetching the credentials ", | ||
| e instanceof Error ? e.message : "Unkown reason" | ||
| ); | ||
| } | ||
| catch(e){ | ||
| console.log("Error Fetching the credentials ", e instanceof Error ? e.message : "Unkown reason"); | ||
| return res | ||
| .status(statusCodes.INTERNAL_SERVER_ERROR) | ||
| .json({ message: "Internal server from fetching the credentials" }); | ||
| } | ||
| } | ||
| ); |
There was a problem hiding this comment.
Inconsistent user ID extraction.
Line 166 uses req.user.sub while other routes (lines 79, 210, 241, 290, 316, 346) consistently use req.user.id. This inconsistency could cause authentication or data retrieval issues.
Please verify which property contains the user ID in the JWT payload. Run the following script to check all usages:
#!/bin/bash
# Search for req.user property access patterns in route handlers
rg -n -C3 'req\.user\.(id|sub)' --type=ts🤖 Prompt for AI Agents
In apps/http-backend/src/routes/userRoutes/userRoutes.ts around lines 156 to
201, the handler uses req.user.sub while the rest of the codebase uses
req.user.id; verify which property the JWT payload actually sets (run the
provided rg script or inspect token parsing), then replace req.user.sub with
req.user.id for consistency, update the userId assignment and related
null/validation checks accordingly, and re-run tests/lint to ensure no other
handlers expect .sub.
| router.get('/getAllCreds', userMiddleware, async(req: AuthRequest, res:Response) =>{ | ||
| try{ | ||
| if(!req.user){ | ||
| return res.status(statusCodes.BAD_REQUEST).json({ | ||
| message: "User is not Loggedin" | ||
| }) | ||
| } | ||
| const userId = req.user.sub; | ||
| const creds = await prismaClient.credential.findMany({ | ||
| where:{ userId: userId} | ||
| }) | ||
| if(creds){ | ||
| return res.status(statusCodes.OK).json({ | ||
| message: "Fetched all credentials of the User!", | ||
| data: creds | ||
| }) | ||
| } | ||
| } | ||
| catch(e){ | ||
| console.log("Error Fetching the credentials ", e instanceof Error ? e.message : "Unkown reason"); | ||
| return res | ||
| .status(statusCodes.INTERNAL_SERVER_ERROR) | ||
| .json({ message: "Internal server from fetching the credentials" }); | ||
| } | ||
| }) |
There was a problem hiding this comment.
Add missing return statement and use consistent user ID property.
Line 210 uses req.user.sub instead of req.user.id (inconsistent with other routes). More critically, there's no return statement after the successful response (line 218), and the catch block (lines 221-226) is outside the try block scope.
🔎 Proposed fix
router.get('/getAllCreds', userMiddleware, async(req: AuthRequest, res:Response) =>{
try{
if(!req.user){
return res.status(statusCodes.BAD_REQUEST).json({
message: "User is not Loggedin"
})
}
- const userId = req.user.sub;
+ const userId = req.user.id;
const creds = await prismaClient.credential.findMany({
where:{ userId: userId}
})
if(creds){
return res.status(statusCodes.OK).json({
message: "Fetched all credentials of the User!",
data: creds
})
}
- }
- catch(e){
+ } catch(e) {
console.log("Error Fetching the credentials ", e instanceof Error ? e.message : "Unkown reason");
return res
.status(statusCodes.INTERNAL_SERVER_ERROR)
.json({ message: "Internal server from fetching the credentials" });
- }
+ }
})🤖 Prompt for AI Agents
In apps/http-backend/src/routes/userRoutes/userRoutes.ts around lines 203-227,
fix the try/catch scope, user ID property, and ensure the handler always
returns: make sure the try block correctly wraps the credential lookup and
response (move the catch so it directly follows the try block), change
req.user.sub to req.user.id to match other routes, and ensure you return after
sending the successful response (or add an explicit return after the if block)
so execution doesn't continue past the response; keep the error catch
immediately after the try and return the internal-server response there.
| router.get('/empty/workflow', userMiddleware, async(req:AuthRequest, res: Response)=>{ | ||
| try{ | ||
| if (!req.user) | ||
| return res | ||
| .status(statusCodes.UNAUTHORIZED) | ||
| .json({ message: "User is not logged in /not authorized" }); | ||
| const userId = req.user.id; | ||
| const workflow = await prismaClient.workflow.findFirst({ | ||
| where:{ | ||
| userId: userId, | ||
| isEmpty: true | ||
| }, | ||
| orderBy: { | ||
| createdAt: 'desc' | ||
| } | ||
| }) | ||
| return res | ||
| .status(statusCodes.OK) | ||
| .json({ message: "Workflow fetched succesful", Data: workflow }); | ||
|
|
||
| }catch(e){ | ||
| console.log("The error is from getting wrkflows", e instanceof Error ? e.message : "UNKNOWN ERROR"); | ||
|
|
||
| return res.status(statusCodes.INTERNAL_SERVER_ERROR).json({ | ||
| meesage: "Internal Server Error From getting workflows for the user", | ||
| }); | ||
| } | ||
| }) |
There was a problem hiding this comment.
Fix typo in error response.
Line 334 has a typo: "meesage" should be "message". Note: The same typo also appears on line 304 in the /workflows route.
🔎 Proposed fix
return res.status(statusCodes.INTERNAL_SERVER_ERROR).json({
- meesage: "Internal Server Error From getting workflows for the user",
+ message: "Internal Server Error From getting workflows for the user",
});Also fix line 304:
return res.status(statusCodes.INTERNAL_SERVER_ERROR).json({
- meesage: "Internal Server Error From getting workflows for the user",
+ message: "Internal Server Error From getting workflows for the user",
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| router.get('/empty/workflow', userMiddleware, async(req:AuthRequest, res: Response)=>{ | |
| try{ | |
| if (!req.user) | |
| return res | |
| .status(statusCodes.UNAUTHORIZED) | |
| .json({ message: "User is not logged in /not authorized" }); | |
| const userId = req.user.id; | |
| const workflow = await prismaClient.workflow.findFirst({ | |
| where:{ | |
| userId: userId, | |
| isEmpty: true | |
| }, | |
| orderBy: { | |
| createdAt: 'desc' | |
| } | |
| }) | |
| return res | |
| .status(statusCodes.OK) | |
| .json({ message: "Workflow fetched succesful", Data: workflow }); | |
| }catch(e){ | |
| console.log("The error is from getting wrkflows", e instanceof Error ? e.message : "UNKNOWN ERROR"); | |
| return res.status(statusCodes.INTERNAL_SERVER_ERROR).json({ | |
| meesage: "Internal Server Error From getting workflows for the user", | |
| }); | |
| } | |
| }) | |
| router.get('/empty/workflow', userMiddleware, async(req:AuthRequest, res: Response)=>{ | |
| try{ | |
| if (!req.user) | |
| return res | |
| .status(statusCodes.UNAUTHORIZED) | |
| .json({ message: "User is not logged in /not authorized" }); | |
| const userId = req.user.id; | |
| const workflow = await prismaClient.workflow.findFirst({ | |
| where:{ | |
| userId: userId, | |
| isEmpty: true | |
| }, | |
| orderBy: { | |
| createdAt: 'desc' | |
| } | |
| }) | |
| return res | |
| .status(statusCodes.OK) | |
| .json({ message: "Workflow fetched succesful", Data: workflow }); | |
| }catch(e){ | |
| console.log("The error is from getting wrkflows", e instanceof Error ? e.message : "UNKNOWN ERROR"); | |
| return res.status(statusCodes.INTERNAL_SERVER_ERROR).json({ | |
| message: "Internal Server Error From getting workflows for the user", | |
| }); | |
| } | |
| }) |
🤖 Prompt for AI Agents
In apps/http-backend/src/routes/userRoutes/userRoutes.ts around lines 304 and
334, there is a typo in the JSON error response key "meesage" — change it to
"message" in both places so the error responses use the correct key; ensure the
surrounding response objects and status codes remain unchanged and run
tests/lint to confirm no other occurrences of the misspelled key.
| const [nodeIDType, setNodeIDType] = useState<string>('') | ||
| const [loadSheet, setLoadSheet] = useState<boolean>(false) | ||
| const [selectedNodeConfig, setSelectedNodeConfig] = useState<any>(undefined); |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Replace any type with a proper interface.
Using any defeats TypeScript's type checking. Define a proper interface for the node configuration shape based on the properties you're accessing (lines 345-349).
🔎 Proposed refactor
+interface NodeConfig {
+ range: string;
+ operation: string;
+ sheetName: string;
+ spreadsheetId: string;
+ credId: string;
+}
+
const [nodeIDType, setNodeIDType] = useState<string>('')
const [loadSheet, setLoadSheet] = useState<boolean>(false)
-const [selectedNodeConfig, setSelectedNodeConfig] = useState<any>(undefined);
+const [selectedNodeConfig, setSelectedNodeConfig] = useState<NodeConfig | undefined>(undefined);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const [nodeIDType, setNodeIDType] = useState<string>('') | |
| const [loadSheet, setLoadSheet] = useState<boolean>(false) | |
| const [selectedNodeConfig, setSelectedNodeConfig] = useState<any>(undefined); | |
| interface NodeConfig { | |
| range: string; | |
| operation: string; | |
| sheetName: string; | |
| spreadsheetId: string; | |
| credId: string; | |
| } | |
| const [nodeIDType, setNodeIDType] = useState<string>('') | |
| const [loadSheet, setLoadSheet] = useState<boolean>(false) | |
| const [selectedNodeConfig, setSelectedNodeConfig] = useState<NodeConfig | undefined>(undefined); |
🤖 Prompt for AI Agents
In apps/web/app/components/nodes/CreateWorkFlow.tsx around lines 42 to 44, the
state selectedNodeConfig is typed as any; define a proper TypeScript interface
(e.g., NodeConfig) that includes the exact properties read at lines 345–349
(make fields optional or typed correctly: their names and types as used there:
string/number/boolean/objects/arrays), replace useState<any> with
useState<NodeConfig | undefined>, export or declare the interface in this file
(or import from a types file), and update any places that set or read
selectedNodeConfig to satisfy the stricter types (add null checks or optional
chaining where needed).
| useEffect(()=>{ | ||
| async function getEmptyWorkflowID(){ | ||
| const workflow = await getEmptyWorkflow() | ||
|
|
||
| if(workflow){ | ||
| const {id, isEmpty} = workflow | ||
| dispatch(workflowActions.setWorkflowId(id)) | ||
| dispatch(workflowActions.setWorkflowStatus(isEmpty)) | ||
| } | ||
| else{ | ||
| if (!userId) return | ||
| const newWorkflow = await createWorkflow() | ||
| dispatch(workflowActions.setWorkflowId(newWorkflow.id)) | ||
| dispatch(workflowActions.setWorkflowStatus(newWorkflow.isEmpty)) | ||
| } | ||
| } | ||
| getEmptyWorkflowID(); | ||
| }, [dispatch]); | ||
| async function getWorkflowData(){ | ||
| if(!workflowId) return | ||
| const workflow = await getworkflowData(workflowId) | ||
| if(workflow.success){ | ||
| dispatch(workflowActions.setWorkflowStatus(false)) | ||
| dispatch(workflowActions.setWorkflowNodes(workflow.data.nodes)) | ||
| dispatch(workflowActions.setWorkflowTrigger(workflow.data.Trigger)) | ||
| // console.log(`workfklow from redux: ${workflow.data}`) | ||
| } | ||
| } | ||
| // if(!workflowId) getEmptyWorkflowID() | ||
| getWorkflowData(); | ||
| },[dispatch, userId, workflowId]) |
There was a problem hiding this comment.
Incomplete workflow initialization logic.
The getEmptyWorkflowID() function is defined but never invoked (line 149 shows it's commented out). This means the workflow initialization flow is incomplete. Additionally, missing error handling could lead to silent failures that would confuse users.
🔎 Proposed fix
useEffect(()=>{
async function getEmptyWorkflowID(){
- const workflow = await getEmptyWorkflow()
+ try {
+ const workflow = await getEmptyWorkflow()
- if(workflow){
- const {id, isEmpty} = workflow
- dispatch(workflowActions.setWorkflowId(id))
- dispatch(workflowActions.setWorkflowStatus(isEmpty))
- }
- else{
- if (!userId) return
- const newWorkflow = await createWorkflow()
- dispatch(workflowActions.setWorkflowId(newWorkflow.id))
- dispatch(workflowActions.setWorkflowStatus(newWorkflow.isEmpty))
+ if(workflow){
+ const {id, isEmpty} = workflow
+ dispatch(workflowActions.setWorkflowId(id))
+ dispatch(workflowActions.setWorkflowStatus(isEmpty))
+ }
+ else{
+ if (!userId) return
+ const newWorkflow = await createWorkflow()
+ dispatch(workflowActions.setWorkflowId(newWorkflow.id))
+ dispatch(workflowActions.setWorkflowStatus(newWorkflow.isEmpty))
+ }
+ } catch (error) {
+ console.error("Error initializing workflow:", error);
}
}
async function getWorkflowData(){
+ try {
- if(!workflowId) return
- const workflow = await getworkflowData(workflowId)
- if(workflow.success){
- dispatch(workflowActions.setWorkflowStatus(false))
- dispatch(workflowActions.setWorkflowNodes(workflow.data.nodes))
- dispatch(workflowActions.setWorkflowTrigger(workflow.data.Trigger))
- // console.log(`workfklow from redux: ${workflow.data}`)
+ if(!workflowId) return
+ const workflow = await getworkflowData(workflowId)
+ if(workflow.success){
+ dispatch(workflowActions.setWorkflowStatus(false))
+ dispatch(workflowActions.setWorkflowNodes(workflow.data.nodes))
+ dispatch(workflowActions.setWorkflowTrigger(workflow.data.Trigger))
+ }
+ } catch (error) {
+ console.error("Error fetching workflow data:", error);
}
}
- // if(!workflowId) getEmptyWorkflowID()
+ if(!workflowId) getEmptyWorkflowID()
getWorkflowData();
},[dispatch, userId, workflowId])| import { GoogleSheetsNodeExecutor } from "@repo/nodes"; | ||
| import axios from "axios"; | ||
| import axios from "axios" | ||
| const date = new Date() |
There was a problem hiding this comment.
Move date instantiation into the function.
The date constant is initialized once at module load time, meaning all workflows created during the application's lifetime will share the same timestamp. Move it inside createWorkflow() to generate unique names.
🔎 Proposed fix
import { BACKEND_URL } from "@repo/common/zod";
import { GoogleSheetsNodeExecutor } from "@repo/nodes";
import axios from "axios"
-const date = new Date()And in the createWorkflow function:
export const createWorkflow = async()=>{
try{
+ const date = new Date();
const response = await axios.post(`${BACKEND_URL}/user/create/workflow`,
{
Name:`workflow-${date.getTime()}`,🤖 Prompt for AI Agents
In apps/web/app/workflow/lib/config.ts around line 4, the module-level const
date = new Date() causes all workflows to share the same timestamp; move the
date instantiation into the createWorkflow() function so a fresh Date() is
created on each invocation and use that local date when generating the workflow
name (replace references to the module-level date with the new local variable).
| export const getAllCredentials = async()=>{ | ||
| try{ | ||
| const res = await axios.get(`${BACKEND_URL}/user/getAllCreds`, { | ||
| withCredentials: true | ||
| }) | ||
| const data = res.data.data | ||
| console.log("credentails: ",data) | ||
| return data | ||
| } | ||
| catch(e){ | ||
| console.error("Error fetching credentials:", e); | ||
| throw e; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| export const getAllWorkflows = async()=>{ | ||
| try{ | ||
| const res = await axios.get(`${BACKEND_URL}/user/workflows`,{ | ||
| withCredentials: true | ||
| }) | ||
| const data = res.data.Data | ||
| console.log("workflows: ",data) | ||
| return data | ||
| }catch(e){ | ||
| console.error("Error fetching credentials:", e); | ||
| throw e; | ||
| } | ||
| } |
There was a problem hiding this comment.
Fix error message and remove console.log statements.
Line 73 has an incorrect error message: "Error fetching credentials" should be "Error fetching workflows" since this is the getAllWorkflows function. Additionally, remove console.log statements on lines 54 and 70 for production code.
🔎 Proposed fix
export const getAllCredentials = async()=>{
try{
const res = await axios.get(`${BACKEND_URL}/user/getAllCreds`, {
withCredentials: true
})
const data = res.data.data
- console.log("credentails: ",data)
return data
}
catch(e){
console.error("Error fetching credentials:", e);
throw e;
}
}
export const getAllWorkflows = async()=>{
try{
const res = await axios.get(`${BACKEND_URL}/user/workflows`,{
withCredentials: true
})
const data = res.data.Data
- console.log("workflows: ",data)
return data
}catch(e){
- console.error("Error fetching credentials:", e);
+ console.error("Error fetching workflows:", e);
throw e;
}
}🤖 Prompt for AI Agents
In apps/web/app/workflow/lib/config.ts around lines 48 to 76, remove the two
console.log statements (currently at lines ~54 and ~70) so no debugging logs are
left in production, and correct the error message in the catch of
getAllWorkflows (around line 73) from "Error fetching credentials" to "Error
fetching workflows"; keep the existing error logging call and rethrowing
behavior unchanged.
| interface Nodecontext{ | ||
| // userId: formData.userId, | ||
| name: string, | ||
| workflowId: string, | ||
| node_Trigger: string, | ||
| position? :number, | ||
| config: { | ||
| credId: string, | ||
| operation: string, | ||
| spreadsheetId: string, | ||
| range: string, | ||
| sheetName: string, | ||
| }, | ||
| }; | ||
| export const createNode = async(context: Nodecontext)=>{ | ||
| try{ | ||
| console.log('Node context: ', context) | ||
|
|
||
| const response = await axios.post(`${BACKEND_URL}/user/create/node`,{ | ||
|
|
||
| Name: context.name, | ||
| AvailableNodeId: context.node_Trigger, | ||
| WorkflowId: context.workflowId, | ||
| Config: context.config, | ||
| Position: context.position ? context.position : 0 | ||
| },{ | ||
| headers: {"Content-Type": "application/json"}, | ||
| withCredentials:true | ||
| }) | ||
|
|
||
| const node = (response.data) | ||
| console.log('Node created: ', node); | ||
| return { | ||
| success: true, | ||
| data: node | ||
| } | ||
|
|
||
| }catch(e){ | ||
| console.error("Error in creating Node:", e); | ||
| return {success: false, | ||
| data: e instanceof Error ? e.message : `unknown error ${e}` | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| export const getEmptyWorkflow = async()=>{ | ||
| try{ | ||
| const res = await axios.get(`${BACKEND_URL}/user/empty/workflow`,{ | ||
| withCredentials: true | ||
| }) | ||
|
|
||
| const workflow = res.data.Data | ||
| return workflow | ||
| } | ||
| catch(e){ | ||
| console.error("Error in fetching workflows:", e); | ||
| throw e; | ||
| } | ||
| } | ||
|
|
||
| export const getworkflowData = async(workflowId: string)=>{ | ||
| try{ | ||
| const res = await axios.get(`${BACKEND_URL}/user/workflow/${workflowId}`,{ | ||
| withCredentials: true | ||
| }) | ||
| console.log('workflow data includes trigger and nodes: ', res.data.Data ) | ||
| return { | ||
| success: true, | ||
| data: res.data.Data | ||
| } | ||
| }catch(e){ | ||
| console.error("Error in creating Node:", e); | ||
| return {success: false, | ||
| data: e instanceof Error ? e.message : `unknown error ${e}` | ||
| }; | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Fix error message and remove console.log statements.
Line 217 has an incorrect error message: "Error in creating Node" should be "Error in fetching workflow data" since this is the getworkflowData function. Additionally, remove console.log statements on lines 162, 177, and 211.
🔎 Proposed fix
export const createNode = async(context: Nodecontext)=>{
try{
- console.log('Node context: ', context)
const response = await axios.post(`${BACKEND_URL}/user/create/node`,{
Name: context.name,
AvailableNodeId: context.node_Trigger,
WorkflowId: context.workflowId,
Config: context.config,
Position: context.position ? context.position : 0
},{
headers: {"Content-Type": "application/json"},
withCredentials:true
})
const node = (response.data)
- console.log('Node created: ', node);
return {
success: true,
data: node
}
}catch(e){
console.error("Error in creating Node:", e);
return {success: false,
data: e instanceof Error ? e.message : `unknown error ${e}`
};
}
}
export const getworkflowData = async(workflowId: string)=>{
try{
const res = await axios.get(`${BACKEND_URL}/user/workflow/${workflowId}`,{
withCredentials: true
})
- console.log('workflow data includes trigger and nodes: ', res.data.Data )
return {
success: true,
data: res.data.Data
}
}catch(e){
- console.error("Error in creating Node:", e);
+ console.error("Error in fetching workflow data:", e);
return {success: false,
data: e instanceof Error ? e.message : `unknown error ${e}`
};
}
}🤖 Prompt for AI Agents
In apps/web/app/workflow/lib/config.ts around lines 146 to 222: remove the three
console.log statements at lines 162, 177 and 211 (these are debug logs printing
Node context, Node created and workflow data) and replace them with no logging
or a proper logger if needed; also fix the incorrect error message on line 217
inside getworkflowData to read "Error in fetching workflow data" instead of
"Error in creating Node", keeping the existing error handling structure and
return values unchanged.
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.