diff --git a/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/with-acl-meta.ts b/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/with-acl-meta.ts index 26ff34fa767..a2d61860c61 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/with-acl-meta.ts +++ b/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/with-acl-meta.ts @@ -52,9 +52,14 @@ function createWithACLMetaMiddleware() { return; } - // @ts-ignore - const primaryKeyField = Model.primaryKeyField || Model.primaryKeyAttribute; + const filterTargetKey = collection.filterTargetKey; + // ensure we only proceed when there is a single string key + if (!filterTargetKey || typeof filterTargetKey !== 'string') { + return; + } + + const primaryKeyField = filterTargetKey; let listData; if (ctx.body?.data) {