fix(logging): add preprocessing util shared by all execution paths#2081
Merged
waleedlatif1 merged 2 commits intostagingfrom Nov 20, 2025
Merged
fix(logging): add preprocessing util shared by all execution paths#2081waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1 merged 2 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile OverviewGreptile SummaryThis PR introduces a centralized Major improvements:
Key behavioral changes:
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant API as API Route (Chat/Webhook/Workflow)
participant Preprocess as preprocessExecution()
participant DB as Database
participant Billing as Billing Service
participant RateLimit as Rate Limiter
participant Logging as LoggingSession
participant Executor as Workflow Executor
Client->>API: POST request (trigger workflow)
API->>Logging: new LoggingSession()
API->>Preprocess: preprocessExecution({workflowId, userId, triggerType, ...})
Note over Preprocess: Step 1: Validate Workflow
Preprocess->>DB: SELECT workflow WHERE id = workflowId
alt Workflow not found
DB-->>Preprocess: No records
Preprocess->>Logging: safeStart() + safeCompleteWithError()
Preprocess-->>API: {success: false, error: {message, statusCode: 404}}
API-->>Client: 404 Workflow not found
end
DB-->>Preprocess: workflow record
Note over Preprocess: Step 2: Check Deployment
alt checkDeployment && !isDeployed
Preprocess->>Logging: safeStart() + safeCompleteWithError()
Preprocess-->>API: {success: false, error: {message, statusCode: 403}}
API-->>Client: 403 Workflow not deployed
end
Note over Preprocess: Step 3: Resolve Billing Actor
Preprocess->>Billing: getWorkspaceBilledAccountUserId(workspaceId)
Billing-->>Preprocess: actorUserId
alt actorUserId is null
alt isResumeContext
Note over Preprocess: Fallback to workflow owner for resume
Preprocess->>Preprocess: Use workflowRecord.userId
else
Preprocess->>Logging: safeStart() + safeCompleteWithError()
Preprocess-->>API: {success: false, error: {statusCode: 500}}
API-->>Client: 500 Unable to resolve billing
end
end
Note over Preprocess: Step 4: Get Subscription
Preprocess->>Billing: getHighestPrioritySubscription(actorUserId)
Billing-->>Preprocess: userSubscription
Note over Preprocess: Step 5: Check Rate Limits
alt checkRateLimit
Preprocess->>RateLimit: checkRateLimitWithSubscription()
RateLimit-->>Preprocess: {allowed, remaining, resetAt}
alt !allowed
Preprocess->>Logging: safeStart() + safeCompleteWithError()
Preprocess-->>API: {success: false, error: {statusCode: 429}}
API-->>Client: 429 Rate limit exceeded
end
end
Note over Preprocess: Step 6: Check Usage Limits
alt !skipUsageLimits
Preprocess->>Billing: checkServerSideUsageLimits(actorUserId)
Billing-->>Preprocess: {isExceeded, currentUsage, limit}
alt isExceeded
Preprocess->>Logging: safeStart() + safeCompleteWithError()
Preprocess-->>API: {success: false, error: {statusCode: 402}}
API-->>Client: 402 Usage limit exceeded
end
end
Note over Preprocess: All checks passed
Preprocess-->>API: {success: true, actorUserId, workflowRecord, userSubscription}
API->>Executor: executeWorkflow(workflow, actorUserId, input)
Executor->>Logging: safeStart()
Executor->>Executor: Execute workflow blocks
Executor->>Logging: safeComplete() / safeCompleteWithError()
Executor-->>API: ExecutionResult
API-->>Client: Response (200/streaming)
|
This was referenced Nov 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type of Change
Testing
Tested manually
Checklist