Skip to content

Port unfinished channel verification feature from BE 1#80

Open
FyreByrd wants to merge 2 commits intodevelopfrom
feat/verify-channels
Open

Port unfinished channel verification feature from BE 1#80
FyreByrd wants to merge 2 commits intodevelopfrom
feat/verify-channels

Conversation

@FyreByrd
Copy link
Copy Markdown
Contributor

@FyreByrd FyreByrd commented Apr 13, 2026

Valid target channels: alpha -> beta -> production

A 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

    • Implemented comprehensive validation for build promotions, including channel transition verification
    • Builds now require successful completion and valid result status before promotion is allowed
    • Invalid promotion requests return specific error codes for improved error diagnostics
  • Chores

    • Refactored internal build channel type system for better type safety

@FyreByrd FyreByrd requested a review from chrisvire April 13, 2026 18:52
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

Warning

Rate limit exceeded

@FyreByrd has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 10 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 125dd158-a1ce-4ff2-a384-03a39f47f155

📥 Commits

Reviewing files that changed from the base of the PR and between 1538345 and 6156c45.

📒 Files selected for processing (1)
  • src/routes/(api)/job/[jobId=idNumber]/build/[buildId=idNumber]/+server.ts
📝 Walkthrough

Walkthrough

Refactored the Build channel system from an enum to a const object with derived union type, introduced a verifyChannel() function for validating channel transitions, and added explicit validation checks to the release creation endpoint to verify build completion, success status, and channel promotion eligibility.

Changes

Cohort / File(s) Summary
Build Channel Refactoring
src/lib/server/models/build.ts
Replaced Channel enum with Channels const object and derived union type. Introduced verifyChannel() function that validates whether a build can transition to a target channel, permitting unpublished channels and checking transition rules for others.
Release Promotion Validation
src/routes/(api)/job/.../+server.ts
Enhanced build field selection to include channel, status, and result. Added pre-release-creation validation: rejects promotion if build status is not Completed (HTTP 409), if build result is not Success (HTTP 403), or if channel transition is invalid per verifyChannel() (HTTP 400).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Constants hop where enums once stood tall,
Transitions mapped—no bad hops at all!
Validations bloom before release takes flight,
Build status checked, results shining bright,
Channel by channel, the pathway flows right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: porting a channel verification feature from a previous version.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/verify-channels

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 817c6e5 and 1538345.

📒 Files selected for processing (2)
  • src/lib/server/models/build.ts
  • src/routes/(api)/job/[jobId=idNumber]/build/[buildId=idNumber]/+server.ts

Comment thread src/lib/server/models/build.ts
Comment thread src/routes/(api)/job/[jobId=idNumber]/build/[buildId=idNumber]/+server.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant