Commit 647ec8b
fix(sharing,driver-sql): a rule authored in Setup actually applies — and switching it off actually withdraws access (#3850)
* fix(sharing,driver-sql): a rule authored in Setup actually applies — and switching it off actually withdraws access (#3821)
**Enabling a rule did nothing to the records already there.** Writing a
`sys_sharing_rule` rebound the per-record hooks, which only makes the rule reach
records written FROM THEN ON. An admin who created a rule and switched it on saw
the recipient's list stay empty until somebody happened to touch each record.
**Switching a rule off did not withdraw access.** Deactivating — or deleting —
left every grant it had already issued in place, and boot backfill only
reconciles ACTIVE rules, so those grants outlived restarts while the UI showed
the rule as disabled. The reconcile existed but was reachable only through
`POST /sharing/rules/:id/evaluate`, which the Console never calls and exposes no
button for.
Each non-system write to `sys_sharing_rule` now also reconciles that rule's
grants, chained behind the existing rebind: insert/update run the same
diff-based `evaluateRule` the REST endpoint runs (it purges when the rule is
inactive), and delete purges directly via the new
`SharingRuleService.revokeRuleGrants` — `evaluateRule` can't help there because
the row is gone (`RULE_NOT_FOUND`), which is also why a rule deleted through the
plain data API used to orphan its grants. Seeding and package bootstrap write
with `isSystem` and are skipped; `kernel:bootstrapped` already backfills those.
Reconciliation is best-effort and never fails the authoring write.
**An unsortable query lost its rows, not just its order.** `SqlDriver.find()`
already recovered from a SELECT projection naming a missing column; the same
failure one clause over — an unknown ORDER BY column — fell through to
`return []`. Because `count()` is a separate statement, the endpoint answered
200 with `records: []` and `total: 3`: the rows are there, none are shown,
nothing is logged. Same family as the `$`-param footgun closed by #2926. It
surfaced through the sharing-rule recipient picker, whose client mangled
`'name asc'` into a list of one-character column names (fixed in objectui).
Rows now outrank their order: the retry ladder drops the projection first, then
the sort, then gives up — an unsortable query returns rows UNORDERED instead of
empty. Non-column errors still propagate.
Also refreshes the `sys_sharing_rule` help text in the zh-CN / ja-JP / es-ES
bundles, which still described `recipient_type` in terms of `department` (the
enum value is `business_unit`) and told admins to enter a queue name for
`recipient_id` (`queue` was removed in ADR-0078). The es-ES option labels for
`position` / `unit_and_subordinates` were translated as "rol".
Browser-verified against the showcase Console: enabling a rule immediately gave
the recipient every matching record, and switching it off took them all away.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(sharing): write the sharing-rule help text for the admin who reads it (#3821)
The field `description`s on `sys_sharing_rule` render as help text under each
input in Setup. They were written as notes for the next engineer:
接收访问权限的主体类型——求值时会展开为用户授权。`business_unit` 会沿
parent_business_unit_id 树展开;`team` 为扁平结构(better-auth);`position`
展开为该岗位的任职人(岗位为扁平结构,ADR-0090 D3)…(ADR-0057 D5)。
ADR numbers, table and column names, a third-party library, and enum machine
values the dropdown never displays — it shows 用户 / 团队 / 业务单元 / 岗位.
Several were also stale, some of them because of this very issue's UI work:
`recipient_id` still said "fill in a business-unit id / team id / position name"
after it became a record picker; `object_name` still said "short object name
(e.g. opportunity, account)" after it became an object picker; `criteria_json`
still described hand-written `FilterCondition` JSON after it became a visual
builder — and carried "(FilterCondition JSON)" in its LABEL.
All of it rewritten for the reader who actually sees it, in en / zh-CN / ja-JP /
es-ES. The engine detail was already in the object's doc comment, which is where
it stays; a comment on the first field now says so, so the next author doesn't
put it back. `active` can finally state what it does — turning it off withdraws
the access — which only became true with the reconcile fix in this branch. The
list page's subtitle and the `managed_by` / `customized` help got the same
treatment.
Browser-verified in the showcase Console: no ADR, table, column, enum or library
name survives anywhere in the create dialog, the detail page or the list header.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent a6c3f38 commit 647ec8b
11 files changed
Lines changed: 390 additions & 63 deletions
File tree
- .changeset
- packages/plugins
- driver-sql/src
- plugin-sharing/src
- objects
- translations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
Lines changed: 98 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
814 | | - | |
| 814 | + | |
| 815 | + | |
815 | 816 | | |
816 | 817 | | |
817 | 818 | | |
| |||
821 | 822 | | |
822 | 823 | | |
823 | 824 | | |
824 | | - | |
| 825 | + | |
825 | 826 | | |
826 | 827 | | |
827 | 828 | | |
| |||
866 | 867 | | |
867 | 868 | | |
868 | 869 | | |
869 | | - | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
870 | 886 | | |
871 | | - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
872 | 890 | | |
873 | | - | |
| 891 | + | |
874 | 892 | | |
875 | | - | |
876 | | - | |
877 | 893 | | |
| 894 | + | |
878 | 895 | | |
879 | 896 | | |
880 | 897 | | |
| |||
Lines changed: 18 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
103 | 109 | | |
104 | 110 | | |
105 | 111 | | |
| |||
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
127 | | - | |
| 133 | + | |
128 | 134 | | |
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
132 | | - | |
| 138 | + | |
133 | 139 | | |
134 | 140 | | |
135 | 141 | | |
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
139 | 145 | | |
140 | | - | |
| 146 | + | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
| |||
150 | 156 | | |
151 | 157 | | |
152 | 158 | | |
153 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
154 | 162 | | |
155 | 163 | | |
156 | 164 | | |
| |||
166 | 174 | | |
167 | 175 | | |
168 | 176 | | |
169 | | - | |
| 177 | + | |
170 | 178 | | |
171 | 179 | | |
172 | 180 | | |
| |||
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
187 | | - | |
| 195 | + | |
188 | 196 | | |
189 | 197 | | |
190 | 198 | | |
| |||
203 | 211 | | |
204 | 212 | | |
205 | 213 | | |
206 | | - | |
207 | | - | |
| 214 | + | |
208 | 215 | | |
209 | 216 | | |
210 | 217 | | |
| |||
219 | 226 | | |
220 | 227 | | |
221 | 228 | | |
222 | | - | |
223 | | - | |
| 229 | + | |
224 | 230 | | |
225 | 231 | | |
226 | 232 | | |
| |||
0 commit comments