Repository navigation
fix(server-core): policy-check denial + typed descendant-tree loading - #3245
Conversation
PolicyCheckerService.check ran engine.evaluate and discarded the result, so a policy denial resolved as success and POST /policies/:id/check reported success: true for a failing policy. Use evaluateOrFail, which throws a PolicyError carrying the evaluation issues, matching the documented check/safeCheck contract.
findDescendantsTreeById built the tree root from an id-only stub; findDescendantsTree() attaches children + extra-attributes but never populates base columns, so every returned tree was type-less and every engine consumer failed closed (policy_evaluator_not_found). Load the row first and return null for an unknown id. Behavioral note: this also affects the Layer-2 junction policy loading (bindings.ts) — a grant restricted via role_permission.policy_id etc. previously always evaluated fail-closed deny; such policies now genuinely evaluate.
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. 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: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ 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 |
authup
@authup/client-web
@authup/server-core
@authup/access
@authup/client-web-kit
@authup/client-web-kit-theme
@authup/client-web-nuxt
@authup/client-web-theme
@authup/core-http-kit
@authup/core-kit
@authup/core-realtime-kit
@authup/errors
@authup/i18n
@authup/kit
@authup/server-adapter-kit
@authup/server-adapter-node
@authup/server-adapter-socket-io
@authup/server-adapter-web
@authup/server-kit
@authup/server-test-kit
@authup/specs
commit: |
Two independent fixes to the policy-evaluation path, found while working on the authorize flow. Both are pre-existing on
masterand unrelated to any feature.1.
PolicyCheckerService.checkreported success on a denialcheck()ranengine.evaluate(...)and discarded the result, so a policy that evaluated to{ success: false }still resolved as success —POST /policies/:id/checkreported a failing policy as passing, contradicting the method's@throwscontract. Switched toengine.evaluateOrFail(...), which throws aPolicyErrorcarrying the evaluation issues. Added a denial regression test to the checker spec (the existing suite only covered the pass and not-found cases).2.
findDescendantsTreeByIdbuilt type-less policy treesThe method rooted the descendants tree on an id-only stub (
this.create(); entity.id = id).EATreeRepository.findDescendantsTree()attaches children + extra-attributes but never populates base columns, so the returned root carried notype— everyPolicyEngineconsumer then failed closed withpolicy_evaluator_not_found. Now loads the row first (findOneBy({ id }),nullon miss) and builds the tree on it.Behavioral change worth calling out: this path is also used for Layer-2 junction-policy loading (
bindings.ts). A grant restricted viarole_permission.policy_id(etc.) previously always evaluated fail-closed deny because its tree was type-less — such policies now genuinely evaluate. No existing test pinned the broken behavior (full suite stays green), but any deployment relying on a junctionpolicy_idrestriction will see it start taking effect.Verification
apps/server-coresuite green.