Title: NocoBase v2.2.4 — belongsTo Create fails with NOT NULL foreign key when ACL whitelist includes association but excludes FK
Environment
- NocoBase v2.2.4
- PostgreSQL 16.8
- Native Collection and Create form
- Role-based Create field whitelist
Problem
We have a Collection crm_sku_sales_price_authorizations with two belongsTo associations:
salesperson→users, foreignKeysalesperson_id, targetKeyidsku→crm_product_skus, foreignKeysku_id, targetKeyid
The Create permission whitelist includes the association fields salesperson and sku, but intentionally excludes the physical foreign key fields to prevent unauthorized direct FK assignment.
The browser submits:
{
"salesperson": {"id": 7},
"sku": {"id": 32},
"quantity_min": 100,
"minimum_authorized_unit_price": 7.1
}
The POST to /api/crm_sku_sales_price_authorizations:create returns HTTP 500:
null value in column "salesperson_id" violates not-null constraint
The database remains unchanged after the failed Create.
Source code observation
In NocoBase v2.2.4, UpdateGuard.sanitize() appears to derive belongsTo foreign keys from association objects before applying the whitelist. The derived foreign keys can then be removed because the whitelist only permits association names.
Relevant source:
packages/core/database/src/update-guard.ts
Questions
- Is this the expected behavior in v2.2.4 or a known issue?
- Is there a supported native configuration that allows Create using belongsTo association objects while preventing clients from directly assigning arbitrary foreign keys?
- Is there a recommended fix or patch for v2.2.4 that preserves record-level access controls?
- If a custom PreAction Handler is required, what is the supported way to retain validated derived foreign keys without weakening ACL enforcement?
We would prefer an officially supported solution rather than modifying NocoBase core or deploying a custom security-sensitive plugin.
No database schema changes or permissions broadening have been applied.