be-update fails misleadingly without record read access
Surfaced by the plan 12 Model Bank smoke <span class="timestamp-wrapper"><span class="timestamp">[2026-08-28 Fri]</span></span>. A user with
type-level update permission (models-user) calling be-update on a
record they cannot read gets a misleading validation error instead of
a permission error.
Repro (modelbank, fresh DB):
- alice inserts a model with no
:rolesargument. The new resource's roles are only("admin" "alice:exclusive"), so peers withmodels-usercannot read it (intended: point-to-point sharing). - bob (has
models-user, no share from alice) calls(be-update :models <id> '(:rating 5) "bob")and gets "Field validation failed: model name must be a valid :TEXT". - bob retries with complete data
'(:name "beta" :rating 5)and gets "FILTERS cannot be NIL [GMN aa378b]".
Verified:
(rec <id> "bob")silently returns NIL (admin and the creator get the full record);be-updatethen proceeds on a nil record.full-databackfills required fields from that nil record, which produces the "name must be :TEXT" error in step 2.be-updatehas no record-level permission gate;be-deletedoes (user-allowed-resource ... "delete"). The type-level update check passes for bob, so nothing rejects the call.- admin and the creator (alice) succeed with identical payloads.
Not yet traced:
- The
valid-filterscall site behind step 3's "FILTERS cannot be NIL" (capture a backtrace first). - Whether the main row UPDATE commits before that error fires (no transactions; a partial write is possible).
Fix directions to weigh:
- Add the record-level gate to
be-update, mirroringbe-delete, so the failure is a clean permission error. - Make
rec's no-access path signal for callers that require the record, instead of silently returning nil.
The default roles on insert (creator exclusive only) are intended; the bug is the misleading failure mode, not the default.
Fix (2026-08-28), per ~/workbench/data-ui-update-perm-plan.org:
lisp/backend.lisp—be-updatenow gates before any side effects:valid-user-permissions ... "update"(type-level),user-allowed-resource ... "update"(record-level, error not silent-skip),valid-existing-uuid, a clean "No record of type ~s matches FILTERS/DATA" for nil-uuid (unmatched filters), and a truthful "Record not found" guard on the loaded record. A carve-out keeps opaque built-in non-base types (:tokens) on the type-level check only, sinceuuid-exists-p/id-to-type-key/user-allowed-resourcecannot see their rows (RESTstore-tokenlogin path regression-tested).tests/update-permission-tests.lisp— new suite on themodelbank-testfixture: peer denial (both repro payloads), no partial write / no write-through orphans, unmatched filters, bogus uuid, creator+admin regression with write-through, base-type:userspath (hash preserved),:tokenscarve-out. Registered indata-ui.asd;run-update-permission-testswired intorun-tests.- Trace result (answers the two open questions): step 3's
"FILTERS cannot be NIL" fired in
update-resource-name→find-resource-name→be-id ... filterswithfilters= the original UUID string passed tobe-update— but reaching it requires the caller-supplied filters to be nil at that point (the repro passed the uuid viadata:id, sofilterswas the record uuid only untilid-from-filters-and-datapreferred the data id). With the gate in place the call dies at the permission check long beforeupdate-resource-name, so the question is moot for unauthorized callers; authorized callers always have a real uuid in =filters=/. The main-row UPDATE had not committed before the old error (it fires between validation and the main update), so no partial write occurred in the repro. recleft alone deliberately: its nil-return contract is load-bearing (be-deletesilent-skip, REST /api/rec empty render). The caller that requires the record now guards explicitly inbe-update.- REST unchanged: the permission error is a validation-error →
400, same convention as
be-action's permission error. A proper 403 needs a distinct condition type — separate small todo if wanted. - Full suite green: 1445 checks, 23 groups. Live modelbank repro:
bob now gets one clean "does not have update permission on
record" for both payloads; alice/admin still write through
(rating 3 landed in
rt_ratings).
- Slot
- 26400
- Status
- 60 Done
- Tags
- backend, bug
- Contributors
- Donnie