fix(bootstrap): harden AppendSchema against list errors and missing metadata description - #1871
fix(bootstrap): harden AppendSchema against list errors and missing metadata description#1871rohilsurana wants to merge 3 commits into
Conversation
…ng on a missing key
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 11 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
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 |
Coverage Report for CI Build 31480747341Coverage increased (+0.05%) to 48.146%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
rohilsurana
left a comment
There was a problem hiding this comment.
Automated code review (xhigh). Findings below. One behavior question, one test-comment fix, a coverage gap, and a small simplification.
What
Fixes two long-standing bugs in
bootstrap.AppendSchema. Both are already onmainand are independent of the boot loader removal work.1. A failed permission list was swallowed
When the list call failed,
AppendSchemareturnednilbeforeapplySchemaran. So a transient list error at boot skipped the schema re-apply but still reported success. Nothing was applied and nothing was dropped, but boot looked healthy while silently doing no schema work. On a first boot, where the base schema has not been applied yet, that leaves the server with no schema at all. The fix returns the wrapped error so boot stops instead of reporting a false success.2. The metadata description read had inverted logic and could panic
The
!okbranch runs only when thedescriptionkey is missing. In that casevis a nilany, sov.(string)panics. When the key is present, the value was ignored and the description was dropped. The logic is now pulled into a smallpermissionDescriptionhelper that reads the value when present, returns""when it is missing or not a string, and never panics.Why now
These are pre-existing bugs, but #1767 removes the boot-time config schema loader and makes
AppendSchemathe only path that applies the schema at boot. That raises how much these two edge cases matter, so it is worth fixing them on their own.Tests
Test_AppendSchemaproves a list error is returned, not swallowed.Test_permissionDescriptioncovers nil metadata, a present string, a missing key, and a non-string value (the last two used to panic).Test_existingPermissionsAsServiceDefinitioncovers the mapping from existing permissions into the schema, so a wrong field or dropped description is caught.go build ./...,go vet ./...,go test ./internal/bootstrap/...pass. gofmt and golangci-lint clean.