Port unfinished channel verification feature from BE 1#80
Port unfinished channel verification feature from BE 1#80
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 10 minutes and 10 seconds. ⌛ 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. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRefactored the Build channel system from an enum to a const object with derived union type, introduced a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/server/models/build.ts`:
- Around line 30-35: The exported validator verifyChannel currently bypasses the
transitions table for Channels.Unpublished and returns true for any target;
update verifyChannel to consult the transitions map instead of special-casing
unpublished so that allowed targets are determined by transitions[
currentChannel ]. Include logic to look up transitions[currentChannel] and check
that the proposed targetChannel is contained in that array (for example using
includes), ensuring Channels.Unpublished only allows the targets listed in
transitions; keep the transitions constant as the source of truth.
In `@src/routes/`(api)/job/[jobId=idNumber]/build/[buildId=idNumber]/+server.ts:
- Around line 69-72: Update the in-flight release check to include
Release.Status.Initialized (i.e. change the where: { status: { in: [...] } }
list to include Release.Status.Initialized) and make the guard atomic: perform
the existence check and row creation inside a single transaction (or add a DB
constraint/unique index that prevents concurrent initialized/active releases for
the same build) so the PUT handler in +server.ts cannot race; ensure the
transaction uses the same ORM methods you already call (wrap the where-query and
the insert/initialize logic together) and handle the transaction error to return
the appropriate “already in progress” response.
- Around line 91-92: The 409 error message uses the wrong property
(build.result) when reporting an incomplete build; update the ErrorResponse call
in the handler that checks Build.Status.Completed to include the actual
build.status (e.g., `${build.status}`) so the message correctly reads "Current
Status: <status>" (refer to the build variable, Build.Status.Completed check,
and ErrorResponse function).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d3d39241-3298-45df-a25c-31c8282a4da3
📒 Files selected for processing (2)
src/lib/server/models/build.tssrc/routes/(api)/job/[jobId=idNumber]/build/[buildId=idNumber]/+server.ts
Valid target channels:
alpha->beta->productionA build may always be released to a channel equal to or greater than its current channel.
Once we are ready, corresponding changes will need to be made in scriptoria to support release channels.
Summary by CodeRabbit
Release Notes
Bug Fixes
Chores