-
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
fix: Release job agent config #289
Conversation
Warning Rate limit exceeded@adityachoudhari26 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 5 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. 📒 Files selected for processing (1)
WalkthroughThis pull request introduces a new function, Changes
Possibly related PRs
Suggested reviewers
Poem
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 comments (1)
apps/event-worker/src/job-dispatch/github.ts (1)
Line range hint
145-153
: Add error handling for repository access.The repository access could fail due to permission issues or network errors. Consider adding specific error handling.
const ref = mergedConfig.ref ?? (await octokit.rest.repos .get({ ...mergedConfig, headers }) .then((r) => r.data.default_branch) .catch((e) => { + if (e.status === 403) { + logger.error(`Permission denied accessing repository for job ${je.id}`, { + error: e, + }); + } else { logger.error(`Failed to get ref for github action job ${je.id}`, { error: e, }); + } return null; }));
🧹 Nitpick comments (1)
apps/event-worker/src/job-dispatch/github.ts (1)
102-103
: Consider handling null config case explicitly.While
_.merge
handles null/undefined cases, it would be more explicit to handle the null case before merging.- const releaseJobAgentConfig = await getReleaseJobAgentConfig(je.id); - const mergedConfig = _.merge(parsedConfig, releaseJobAgentConfig); + const releaseJobAgentConfig = await getReleaseJobAgentConfig(je.id); + const mergedConfig = _.merge({}, parsedConfig, releaseJobAgentConfig ?? {});
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/event-worker/src/job-dispatch/github.ts
(5 hunks)packages/db/drizzle/0062_right_the_watchers.sql
(1 hunks)packages/db/drizzle/meta/_journal.json
(1 hunks)packages/db/src/schema/release.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/db/src/schema/release.ts (1)
Pattern **/*.{ts,tsx}
: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.
apps/event-worker/src/job-dispatch/github.ts (1)
Pattern **/*.{ts,tsx}
: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Typecheck
- GitHub Check: build (linux/amd64)
- GitHub Check: Lint
🔇 Additional comments (3)
packages/db/drizzle/0062_right_the_watchers.sql (1)
1-1
: LGTM! Migration looks good.The migration adds a new JSONB column with appropriate constraints and default value.
packages/db/drizzle/meta/_journal.json (1)
439-444
: LGTM! Migration journal entry is consistent.The entry follows the established format and maintains consistency with previous entries.
apps/event-worker/src/job-dispatch/github.ts (1)
73-80
: LGTM! Well-structured database query.The function follows SQL query best practices and properly handles null cases.
jobAgentConfig: jsonb("job_agent_config") | ||
.notNull() | ||
.default("{}") | ||
.$type<Record<string, any>>(), |
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.
Add jobAgentConfig to createRelease schema.
The field is added to the table schema but not included in the createRelease
schema. This could lead to type safety issues.
Add the field to the schema:
export const createRelease = createInsertSchema(release, {
version: z.string().min(1),
name: z.string().optional(),
config: z.record(z.any()),
+ jobAgentConfig: z.record(z.any()),
status: z.nativeEnum(ReleaseStatus),
createdAt: z
.string()
.transform((s) => new Date(s))
.optional(),
})
Committable suggestion skipped: line range outside the PR's diff.
owner: mergedConfig.owner, | ||
repo: mergedConfig.repo, | ||
workflow_id: mergedConfig.workflowId, | ||
ref, | ||
inputs: { job_id: je.id }, | ||
headers, |
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.
Add error handling for workflow dispatch.
The workflow dispatch operation could fail, but there's no error handling.
- await octokit.actions.createWorkflowDispatch({
- owner: mergedConfig.owner,
- repo: mergedConfig.repo,
- workflow_id: mergedConfig.workflowId,
- ref,
- inputs: { job_id: je.id },
- headers,
- });
+ try {
+ await octokit.actions.createWorkflowDispatch({
+ owner: mergedConfig.owner,
+ repo: mergedConfig.repo,
+ workflow_id: mergedConfig.workflowId,
+ ref,
+ inputs: { job_id: je.id },
+ headers,
+ });
+ } catch (error) {
+ logger.error(`Failed to dispatch workflow for job ${je.id}`, { error });
+ await db
+ .update(job)
+ .set({
+ status: JobStatus.InvalidJobAgent,
+ message: `Failed to dispatch workflow: ${error.message}`,
+ })
+ .where(eq(job.id, je.id));
+ return;
+ }
Committable suggestion skipped: line range outside the PR's diff.
Summary by CodeRabbit
Database Changes
job_agent_config
column to therelease
table to store job agent configuration.Configuration Handling
Testing
jobAgentConfig
property in the release object.