-
Notifications
You must be signed in to change notification settings - Fork 1
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
Move variable resolution to job dispatch time #167
Conversation
Warning Rate limit exceeded@zacharyblasczyk has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 9 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes in this pull request introduce the Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
packages/job-dispatch/src/job-dispatch.ts (1)
Line range hint
71-116
: Review transaction management across async operationsThe code performs multiple async operations (variable creation, queue updates, status updates) using a passed-in transaction. There's a risk of partial completion if the transaction isn't properly managed at the caller level.
Consider:
- Documenting the transaction requirements for callers
- Ensuring the passed transaction is committed atomically with queue operations
- Adding integration tests to verify atomicity of these operations
Would you like me to help create a test suite that verifies the transaction boundaries?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
- packages/job-dispatch/src/job-dispatch.ts (3 hunks)
- packages/job-dispatch/src/release-job-trigger.ts (0 hunks)
💤 Files with no reviewable changes (1)
- packages/job-dispatch/src/release-job-trigger.ts
🔇 Additional comments (1)
packages/job-dispatch/src/job-dispatch.ts (1)
9-9
: LGTM: Clean import additionThe import is appropriately placed and follows the existing import organization pattern.
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
packages/job-dispatch/src/job-dispatch.ts (1)
Based on the results, I can now provide the final response:
Error handling improvements needed for dispatch() and dispatchRunbook() callers
The verification reveals that most callers don't properly handle potential errors from the variable resolution process. Specific issues:
None of the
dispatch()
callers wrap the call in try-catch blocks:
packages/api/src/router/job.ts
packages/api/src/router/release.ts
(multiple locations)packages/api/src/router/environment.ts
apps/webservice/src/app/api/v1/releases/route.ts
apps/webservice/src/app/api/v1/config/route.ts
apps/jobs/src/policy-checker/index.ts
The
dispatchRunbook
caller inpackages/api/src/router/runbook.ts
doesn't handle potential errors either.Since these functions can now fail during variable resolution, errors should be caught and handled appropriately to prevent unhandled promise rejections and provide proper error feedback to users.
🔗 Analysis chain
Line range hint
1-142
: Verify error handling in callersSince both
dispatch()
anddispatchRunbook()
functions can now throw errors during variable resolution, we should verify that all callers handle these errors appropriately.Let's check the usage:
Let me generate additional scripts to verify the error handling in the callers we found.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Find all callers of dispatch() and dispatchRunbook() echo "Searching for dispatch() callers:" rg -A 3 "dispatch\(\)" --type ts echo -e "\nSearching for dispatchRunbook callers:" rg -A 3 "dispatchRunbook\(" --type ts # Verify the removal of createReleaseVariables from release-job-trigger echo -e "\nVerifying removal from release-job-trigger:" rg "createReleaseVariables" "release-job-trigger.ts"Length of output: 2871
Script:
#!/bin/bash # Check error handling in dispatch() callers echo "Checking error handling in dispatch() callers:" echo -e "\nChecking packages/job-creation.ts:" rg -B 5 -A 5 "dispatch\(\)" packages/job-creation.ts echo -e "\nChecking packages/api/src/router/job.ts:" rg -B 5 -A 5 "dispatch\(\)" packages/api/src/router/job.ts echo -e "\nChecking packages/api/src/router/release.ts:" rg -B 5 -A 5 "dispatch\(\)" packages/api/src/router/release.ts echo -e "\nChecking packages/api/src/router/environment.ts:" rg -B 5 -A 5 "dispatch\(\)" packages/api/src/router/environment.ts echo -e "\nChecking apps/webservice/src/app/api/v1/releases/route.ts:" rg -B 5 -A 5 "dispatch\(\)" apps/webservice/src/app/api/v1/releases/route.ts echo -e "\nChecking apps/webservice/src/app/api/v1/config/route.ts:" rg -B 5 -A 5 "dispatch\(\)" apps/webservice/src/app/api/v1/config/route.ts echo -e "\nChecking apps/jobs/src/policy-checker/index.ts:" rg -B 5 -A 5 "dispatch\(\)" apps/jobs/src/policy-checker/index.ts echo -e "\nChecking dispatchRunbook error handling:" rg -B 5 -A 5 "dispatchRunbook\(" packages/api/src/router/runbook.tsLength of output: 4266
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- packages/job-dispatch/src/job-dispatch.ts (3 hunks)
🔇 Additional comments (1)
packages/job-dispatch/src/job-dispatch.ts (1)
9-9
: LGTM: Import statement is correctly placedThe import of
createReleaseVariables
is properly organized with related imports.
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.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- packages/job-dispatch/src/job-dispatch.ts (3 hunks)
🔇 Additional comments (2)
packages/job-dispatch/src/job-dispatch.ts (2)
9-9
: LGTM: Import added correctlyThe import for createReleaseVariables is properly placed and follows the project's import structure.
94-115
: 🛠️ Refactor suggestionSimplify type assertions and bulk updates
The type assertions and filtering for undefined values are redundant since we're working with array indices that match the results array.
Consider simplifying:
- if (jobsWithResolvedVariables.length > 0) { await dispatchJobsQueue.addBulk( - jobsWithResolvedVariables - .filter((wf): wf is schema.Job => wf !== undefined) - .map((wf) => ({ + jobsWithResolvedVariables.map((wf) => ({ name: wf.id, data: { jobId: wf.id }, })), ); await this.db .update(schema.job) .set({ status: JobStatus.InProgress }) .where( inArray( schema.job.id, - jobsWithResolvedVariables - .filter((j): j is schema.Job => j !== undefined) - .map((j) => j.id), + jobsWithResolvedVariables.map((j) => j.id), ), ); - }Likely invalid or redundant comment.
Summary by CodeRabbit
New Features
Bug Fixes
ReleaseJobTriggerBuilder
by removing unused functionality related to release variable creation, ensuring smoother job insertion processes.