Changelog - 2026-10-25
scopeFilter now holds writes to the scope
Breaking Change Security EnhancementIn one line. A model with settings.access (then settings.scopeFilter) scoped reads and where-based updates and deletes, but a create or an update payload could still put a row in another scope. The repository now refuses that write, and writes nothing.
What changed
- Create and createAll are checked. Each row's scope columns must hold a value the resolved scope allows. One bad row refuses the whole
createAll. - An update payload that names a scope column is checked. An update that moves a row to another scope, or sets the column to
null, is refused. An update that does not name the column is not checked: the scopedwherealready confines it. - The scope is read from the resolved
where. Equality,eq,inqorin, an array,andof those, and anorwhose branches all constrain the same column. Another shape (anorover several columns, ranges,like, a nested path) cannot be checked, and the write is refused with its own message. - New settings on
access.write.mode: 'reject' | 'assign'(defaultreject),write.sharedRows: trueto allownull, and an optionalcolumnslist.assignfills a scope column that is absent from a created row when the scope is a single equality; a value that is present and disagrees is still refused, and aninqscope cannot be assigned. See Model settings and the regrouping. sharedRowsgrants writing shared rows. Withwrite.sharedRows: true, a restricted caller may create a row withnullor no value in the scope column, or move a row into the shared set. Without it,nulland an absent column are refused.columnsmoves a failure to boot. When declared, each name must exist on the model, checked at boot. Without it the guard checks every column the resolved scope constrains, at write time.
The refusal is HTTP 403, code core.repository.scope_write_denied. It names the entity and the column, never a value:
[create] write refused by the access scope | entity: pricing_rules | column: merchantId | the value is outside the resolved scopeWho is affected
- Models with an
accessscope whose code creates, or moves, rows in another scope under a resolver that returns awhere: a webhook, a provisioning worker, an admin back office. Their writes now fail. - Models with a nullable scope column that stores shared rows (
null). Setwrite.sharedRows: trueon the model. Anullbranch in the scope, as in{ or: [{ merchantId: { in: ids } }, { merchantId: null }] }, lets the caller read shared rows only; restricted callers still cannot write shared rows unlesssharedRowsis true. - A create with no scope column set now fails, unless
write.mode: 'assign'fills it orwrite.sharedRowsis on. - Models whose scope is built with an
orover several columns, ranges orlike. Writes are refused as unverifiable. Express the scope with equality orinq, or returnUNRESTRICTEDfor that caller. - A create while the scope cannot be resolved (
resolve()returnsnullandonMissingisdeny) is refused. An update there still matches no row, as before.
Breaking changes
WARNING
Writes that cross scopes, or leave the scope column unset, now fail. Return ScopeFilters.UNRESTRICTED from resolve() for the caller that may write across scopes, such as a system scope or an admin role.
@model({
type: 'entity',
settings: {
access: {
resolve: () => (isSystemScope() ? ScopeFilters.UNRESTRICTED : { merchantId: currentMerchantId() }),
write: { sharedRows: true },
},
},
})
class PricingRule extends BaseRelationalEntity<typeof pricingRules> {}UNRESTRICTED bypasses the write guard as it bypasses the read scope: rows are written exactly as given and nothing is stamped. It is a symbol no request can produce, so the decision stays in code your application wrote. There is no global switch to turn the guard off.
Not covered: raw drizzle statements that bypass the repository, and an update that does not name the scope column.