-
Notifications
You must be signed in to change notification settings - Fork 0
feat: enhance workflow execution logging, add Gmail node, and update … #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"root":["./src/index.ts","./src/routes/google_callback.ts","./src/routes/nodes.routes.ts","./src/routes/userRoutes/userMiddleware.ts","./src/routes/userRoutes/userRoutes.ts"],"version":"5.7.3"} | ||
| {"root":["./src/index.ts","./src/routes/google_callback.ts","./src/routes/nodes.routes.ts","./src/routes/userroutes/usermiddleware.ts","./src/routes/userroutes/userroutes.ts","./src/scheduler/token-scheduler.ts","./src/services/token-refresh.service.ts"],"version":"5.7.3"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = { | ||
| transpilePackages: ["@workspace/ui"], | ||
| transpilePackages: ["@workspace/ui", "@repo/db"], | ||
| serverExternalPackages: ["@prisma/client", "prisma"], | ||
| } | ||
|
|
||
| export default nextConfig |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,32 +34,36 @@ export async function executeWorkflow( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: "InProgress", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(!update.error) console.log('updated the workflow execution') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const nodes = data?.workflow.nodes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`Total nodes - ${nodes.length}`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const node of nodes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`${node.name}, ${node.position}th - started Execution`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const nodeType = node.AvailableNode.type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const context = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nodeId: node.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // nodeId: node.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| userId: data.workflow.userId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| credentialId: node.credentials[0]?.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| credId: node.credentials[0]?.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+46
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# First, let's find and view the executor.ts file
find . -name "executor.ts" -type f | grep -v node_modules | head -20Repository: Dev-Pross/BuildFlow Length of output: 99 🏁 Script executed: #!/bin/bash
# Let's look at the structure around lines 46-48 in the executor file
if [ -f "apps/worker/src/engine/executor.ts" ]; then
echo "=== File content around lines 40-55 ==="
cat -n "apps/worker/src/engine/executor.ts" | sed -n '40,55p'
fiRepository: Dev-Pross/BuildFlow Length of output: 828 🏁 Script executed: #!/bin/bash
# Search for all references to credentialId in TypeScript files
echo "=== Searching for 'credentialId' usage ==="
rg -n 'credentialId' --type ts -C 2 | head -100Repository: Dev-Pross/BuildFlow Length of output: 8361 🏁 Script executed: #!/bin/bash
# Search for references to nodeId in executor-related files
echo "=== Searching for 'nodeId' in executor files ==="
rg -n 'nodeId' --type ts -g '*executor*' -C 2 | head -100Repository: Dev-Pross/BuildFlow Length of output: 470 🏁 Script executed: #!/bin/bash
# Find all executor class implementations
echo "=== Finding executor implementations ==="
fd 'executor' --type f -e ts | grep -v node_modules | grep -v '.next'Repository: Dev-Pross/BuildFlow Length of output: 240 🏁 Script executed: #!/bin/bash
# Find the NodeExecutionContext type definition
echo "=== Finding NodeExecutionContext definition ==="
rg -n "NodeExecutionContext" --type ts | head -20Repository: Dev-Pross/BuildFlow Length of output: 1426 🏁 Script executed: #!/bin/bash
# Look at the types.ts or interface files
find . -name "types.ts" -o -name "*types.ts" | grep -v node_modules | head -10Repository: Dev-Pross/BuildFlow Length of output: 154 🏁 Script executed: #!/bin/bash
# Check gmail executor implementation
if [ -f "packages/nodes/src/gmail/gmail.executor.ts" ]; then
echo "=== Gmail executor context usage ==="
cat -n "packages/nodes/src/gmail/gmail.executor.ts" | grep -A 5 -B 5 "context.cred"
fiRepository: Dev-Pross/BuildFlow Length of output: 482 🏁 Script executed: #!/bin/bash
# Search for any usage of context.credentialId (the old field name)
echo "=== Searching for 'context.credentialId' usage ==="
rg -n 'context\.credentialId' --type tsRepository: Dev-Pross/BuildFlow Length of output: 113 🏁 Script executed: #!/bin/bash
# Check if NodeExecutionContext is defined with credId or credentialId
echo "=== Searching for NodeExecutionContext definition ==="
rg -n "interface NodeExecutionContext|type NodeExecutionContext" --type ts -A 10Repository: Dev-Pross/BuildFlow Length of output: 1740 🏁 Script executed: #!/bin/bash
# Check worker types.ts for NodeExecutionContext
if [ -f "apps/worker/src/types.ts" ]; then
echo "=== Worker types.ts content ==="
cat -n "apps/worker/src/types.ts"
fiRepository: Dev-Pross/BuildFlow Length of output: 576 🏁 Script executed: #!/bin/bash
# Check if nodeId is used anywhere in the codebase
echo "=== Searching for references to node.id or nodeId usage ==="
rg -n "node\.id" --type ts apps/worker/src/engine/ -A 2 -B 2Repository: Dev-Pross/BuildFlow Length of output: 481 🏁 Script executed: #!/bin/bash
# Search for any executor that might expect nodeId
echo "=== Checking if any code expects nodeId in context ==="
rg -n "context\.nodeId|nodeId" --type ts packages/nodes/ | head -20Repository: Dev-Pross/BuildFlow Length of output: 277 🏁 Script executed: #!/bin/bash
# Check if there's a type mismatch - does credId match credentialsId?
echo "=== Checking type definition mismatch ==="
echo "Type definition in types.ts line 4:"
sed -n '4p' apps/worker/src/types.ts
echo ""
echo "Actual context object line 48 in executor.ts:"
sed -n '48p' apps/worker/src/engine/executor.ts
echo ""
echo "Executor interface definition in google-sheets:"
grep -A 5 "interface NodeExecutionContext" packages/nodes/src/google-sheets/google-sheets.executor.ts | head -6Repository: Dev-Pross/BuildFlow Length of output: 460 🏁 Script executed: #!/bin/bash
# Search for any usage of context.credentialsId (the type definition name)
echo "=== Checking if credentialsId is used anywhere ==="
rg -n 'context\.credentialsId|credentialsId' --type ts | head -20Repository: Dev-Pross/BuildFlow Length of output: 166 🏁 Script executed: #!/bin/bash
# Check if there are TypeScript compilation errors or type incompatibilities
echo "=== Looking for tsconfig and checking overall type structure ==="
find . -name "tsconfig.json" | head -5Repository: Dev-Pross/BuildFlow Length of output: 272 Fix type definition mismatch in ExecutionContext interface. The context object passed to executors uses credId?: string; // instead of credentialsId?: string;The 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config: node.config as Record<string, any>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputData: currentInputData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`Executing with context: ${context}`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix object logging to output readable JSON. The template literal 🔎 Proposed fix- console.log(`Executing with context: ${context}`)
+ console.log(`Executing with context: ${JSON.stringify(context, null, 2)}`)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const execute = await register.execute(nodeType, context); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!execute.success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await prismaClient.workflowExecution.update({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| where: { id: workflowExecutionId }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: "Failed", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error: execute.error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| completedAt: new Date(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // if (!execute.success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // await prismaClient.workflowExecution.update({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // where: { id: workflowExecutionId }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // data: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // status: "Failed", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // error: execute.error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // completedAt: new Date(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+54
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Restore error handling for failed node executions. The error handling block that marks workflows as "Failed" has been completely commented out. This means:
This breaks the core execution contract and will mislead users about workflow success/failure status. 🔎 Proposed fix to restore error handling console.log(`Executing with context: ${context}`)
const execute = await register.execute(nodeType, context);
- // if (!execute.success) {
- // await prismaClient.workflowExecution.update({
- // where: { id: workflowExecutionId },
- // data: {
- // status: "Failed",
- // error: execute.error,
- // completedAt: new Date(),
- // },
- // });
- // return;
- // }
+ if (!execute.success) {
+ await prismaClient.workflowExecution.update({
+ where: { id: workflowExecutionId },
+ data: {
+ status: "Failed",
+ error: execute.error,
+ completedAt: new Date(),
+ },
+ });
+ console.log(`Workflow failed at node ${node.name}: ${execute.error}`);
+ return;
+ }
currentInputData = execute.output;
console.log("output: ", JSON.stringify(execute))📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currentInputData = execute.output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("output: ", JSON.stringify(execute)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const updatedStatus = await prismaClient.workflowExecution.update({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| where: { id: workflowExecutionId }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||
| import { ExecutionContext, ExecutionResult, NodeExecutor } from "../types.js"; | ||||||
| import { GmailExecutor } from "@repo/nodes/nodeClient"; | ||||||
| import {GoogleSheetsNodeExecutor} from "@repo/nodes/nodeClient"; | ||||||
| class ExecutionRegistry { | ||||||
| private executors = new Map<string, NodeExecutor>(); | ||||||
|
|
||||||
|
|
@@ -19,7 +20,7 @@ class ExecutionRegistry { | |||||
| }; | ||||||
| } | ||||||
| try { | ||||||
| const result = await executor.execute(context); | ||||||
| const result = await executor.execute(context) | ||||||
| console.log("Execute result:", result); | ||||||
|
|
||||||
| return result; | ||||||
|
|
@@ -38,6 +39,7 @@ class ExecutionRegistry { | |||||
|
|
||||||
| //wehen visits this next time make sure chang gmail executor implements NodeExecutor | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in comment. "wehen" should be "when". 🔎 Proposed fix- //wehen visits this next time make sure chang gmail executor implements NodeExecutor
+ //when someone visits this next time make sure to change gmail executor to implement NodeExecutor📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| this.register("gmail", new GmailExecutor() as unknown as NodeExecutor); | ||||||
| this.register("google_sheet", new GoogleSheetsNodeExecutor() as unknown as NodeExecutor) | ||||||
| console.log(`The current Executors are ${this.executors.size}`); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,15 @@ | ||||||||||||||||||||
| import { Kafka } from "kafkajs"; | ||||||||||||||||||||
| import { executeWorkflow } from "./engine/executor.js"; | ||||||||||||||||||||
| import { register } from "./engine/registory.js"; | ||||||||||||||||||||
| const kafka = new Kafka({ | ||||||||||||||||||||
| // clientId: "Processing App", | ||||||||||||||||||||
| clientId: "BuildFlow-Worker", | ||||||||||||||||||||
| brokers: ["localhost:9092"], | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| const TOPIC_NAME = "First-Client"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| register.initialize() | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for executor initialization. The 🔎 Proposed fix-register.initialize()
-
+try {
+ register.initialize();
+ console.log("✅ Executors initialized successfully");
+} catch (error) {
+ console.error("❌ Failed to initialize executors:", error);
+ process.exit(1);
+}
+📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| async function main() { | ||||||||||||||||||||
| const consumer = kafka.consumer({ groupId: "test-group" }); | ||||||||||||||||||||
| await consumer.connect(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"root":["./src/index.ts","./src/test.ts","./src/types.ts","./src/engine/executor.ts","./src/engine/registory.ts"],"version":"5.7.3"} | ||
| {"root":["./src/index.ts","./src/types.ts","./src/engine/executor.ts","./src/engine/registory.ts","./src/tests/create-execution.ts","./src/tests/setup-test.ts","./src/tests/test.ts","./src/tests/update-node.ts"],"version":"5.7.3"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,4 +24,4 @@ | |
| "dotenv": "^17.2.3", | ||
| "prisma": "^6.19.0" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"root":["./src/index.ts","./src/seed.ts"],"version":"5.9.2"} | ||
| {"root":["./src/index.ts","./src/seed.ts"],"version":"5.7.3"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import NodeRegistry from "../registry/node-registry.js"; | ||
| import { GmailExecutor } from "./gmail.executor.js"; | ||
|
|
||
| export class GmailNode { | ||
| static definition = { | ||
| name: "Gmail", | ||
| type: "gmail", | ||
| description: 'Communicate with Gmail', | ||
| config: { | ||
| fields:[ | ||
| { | ||
| name: "From", | ||
| type: "email", | ||
| require: true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo: The property name 🔎 Proposed fix {
name: "From",
type: "email",
- require: true
+ required: true
},
{
name: "To",
type: "email",
- require: true
+ required: true
},
{
name:"Body",
type: "textArea",
- require: true
+ required: true
}Also applies to: 19-19, 24-24 🤖 Prompt for AI Agents |
||
| }, | ||
|
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Search for gmail-related service and executor implementations
find packages/nodes/src/gmail -type f -name "*.ts" | head -20Repository: Dev-Pross/BuildFlow Length of output: 186 🏁 Script executed: # Look at the gmail.node.ts file structure to understand the From field context
wc -l packages/nodes/src/gmail/gmail.node.tsRepository: Dev-Pross/BuildFlow Length of output: 104 🏁 Script executed: # Search for GmailExecutor and GmailService implementations
rg -l "GmailExecutor|GmailService" packages/nodes/src/gmail/ --type=tsRepository: Dev-Pross/BuildFlow Length of output: 186 🏁 Script executed: # Read the entire gmail.node.ts file to understand context
cat -n packages/nodes/src/gmail/gmail.node.tsRepository: Dev-Pross/BuildFlow Length of output: 1532 🏁 Script executed: # Read gmail.executor.ts to see how From field is used
cat -n packages/nodes/src/gmail/gmail.executor.tsRepository: Dev-Pross/BuildFlow Length of output: 2555 🏁 Script executed: # Read gmail.service.ts to see OAuth and sender logic
cat -n packages/nodes/src/gmail/gmail.service.tsRepository: Dev-Pross/BuildFlow Length of output: 3754 Remove the "From" field entirely—it is never used and users are forced to enter a required value that is ignored. The code extracts only 🤖 Prompt for AI Agents |
||
| { | ||
| name: "To", | ||
| type: "email", | ||
| require: true | ||
| }, | ||
| { | ||
| name:"Body", | ||
| type: "textArea", | ||
| require: true | ||
| } | ||
| ] | ||
|
Comment on lines
+10
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing required "Subject" field for email composition. Email messages typically require a subject line. The current configuration only includes From, To, and Body fields, but is missing a Subject field. 🔎 Suggested addition fields:[
{
name: "From",
type: "email",
required: true
},
{
name: "To",
type: "email",
required: true
},
+ {
+ name: "Subject",
+ type: "text",
+ required: true
+ },
{
name:"Body",
type: "textArea",
required: true
}
]
🤖 Prompt for AI Agents |
||
| }, | ||
| requireAuth: true, | ||
| authType: 'google_oauth' | ||
|
|
||
| }; | ||
|
|
||
| static async register(){ | ||
| await NodeRegistry.register(this.definition) | ||
| // console.log(`✅ Registered node: ${this.definition.name}`); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Remove commented-out debug logs. These commented console.log statements are debug artifacts that should be removed to keep the codebase clean. 🔎 Proposed cleanup static async register(){
await NodeRegistry.register(this.definition)
- // console.log(`✅ Registered node: ${this.definition.name}`);
await NodeRegistry.registerTrigger(this.definition)
- // console.log(`✅ Registered Trigger: ${this.definition.name}`);
}Also applies to: 37-37 🤖 Prompt for AI Agents |
||
| await NodeRegistry.registerTrigger(this.definition) | ||
| // console.log(`✅ Registered Trigger: ${this.definition.name}`); | ||
| } | ||
|
|
||
| static getExecutor(){ | ||
| return new GmailExecutor(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suspicious error check on Prisma update result.
The condition
if(!update.error)will always be true because Prisma'supdateoperation throws exceptions on errors rather than returning an object with anerrorfield. If error checking is intended here, wrap the update in a try-catch block instead.🔎 Proposed fix if error handling is needed
🤖 Prompt for AI Agents