Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App error - Collection model roles has no primary key attribute #4037

Closed
jamesgid-gc opened this issue Apr 15, 2024 · 3 comments
Closed

App error - Collection model roles has no primary key attribute #4037

jamesgid-gc opened this issue Apr 15, 2024 · 3 comments

Comments

@jamesgid-gc
Copy link

Describe the bug

Hi team. I am very new to Nocobase, so my apologies if I have missed something basic. Using Portainer, I created a nocobase container and was able to use it. However, it was completely default with no env variables, so nothing was persistent. I have since created a contaner for MariaDB and then declared env variables for nocobase. However, upon starting the container I see 'App error - Collection model roles has no primary key attribute' error in the web interface.
The data base connection is working because tables have been created. Not sure what else I have missed.
The log file also has these entries:
copying... yarn run v1.22.19 $ nocobase create-nginx-conf Done in 0.28s. nginx started yarn run v1.22.19 $ nocobase start --quickstart 2024-04-15T03:13:55: PM2 log: Launching in no daemon mode 2024-04-15T03:13:55: PM2 log: App [index:0] starting in -fork mode- 2024-04-15T03:13:55: PM2 log: App [index:0] online Gateway IPC Server running at /app/nocobase/storage/gateway.sock Gateway HTTP Server running at http://0.0.0.0:13000/ INF add app main into supervisor | meta={} module=application submodule=supervisor method=addApp app=main reqId=de4e2b6e-0a20-449d-a1e0-bb495b728856 timestamp=2024-04-15 03:13:57 INF connection has been established successfully. | meta={} module=database submodule= method=auth app=main reqId=de4e2b6e-0a20-449d-a1e0-bb495b728856 timestamp=2024-04-15 03:13:57 INF upgrading... | meta={} module=application submodule= method= app=main reqId=de4e2b6e-0a20-449d-a1e0-bb495b728856 timestamp=2024-04-15 03:13:57 INF run upgrade | meta={} module=application submodule= method= app=main reqId=de4e2b6e-0a20-449d-a1e0-bb495b728856 timestamp=2024-04-15 03:13:57 INF update built-in plugins | meta={} module=nocobase submodule= method= app=main reqId=de4e2b6e-0a20-449d-a1e0-bb495b728856 timestamp=2024-04-15 03:13:57 new client connected ravcxOTIfoOjJZiv-e9xs client tags: app#main INF run upgrade | meta={} module=application submodule= method= app=main reqId=de4e2b6e-0a20-449d-a1e0-bb495b728856 timestamp=2024-04-15 03:13:59 INF restarting... | meta={} module=application submodule= method= app=main reqId=de4e2b6e-0a20-449d-a1e0-bb495b728856 timestamp=2024-04-15 03:13:59 INF app.reload() | meta={} module=application submodule= method=load app=main reqId=de4e2b6e-0a20-449d-a1e0-bb495b728856 timestamp=2024-04-15 03:13:59 ERR Collection model roles has no primary key attribute | stack=Error: Collection model roles has no primary key attribute at _BelongsToManyField.bind (/app/nocobase/node_modules/@nocobase/database/lib/fields/belongs-to-many-field.js:107:13) at _Collection.<anonymous> (/app/nocobase/node_modules/@nocobase/database/lib/collection.js:621:13) at _Collection.emit (node:events:517:28) at _Collection.emit (node:domain:489:12) at _Collection.setField (/app/nocobase/node_modules/@nocobase/database/lib/collection.js:267:10) at EnsureAtomicity.descriptor.value (/app/nocobase/node_modules/@nocobase/database/lib/collection.js:58:29) at /app/nocobase/node_modules/@nocobase/plugin-collection-manager/dist/server/models/field.js:45:25 at async model.load (/app/nocobase/node_modules/@nocobase/plugin-collection-manager/dist/server/models/field.js:43:19) at async model.loadFields (/app/nocobase/node_modules/@nocobase/plugin-collection-manager/dist/server/models/collection.js:110:7) at async CollectionRepository.load (/app/nocobase/node_modules/@nocobase/plugin-collection-manager/dist/server/repositories/collection-repository.js:119:7) meta={} module=application submodule= method= app=main reqId=de4e2b6e-0a20-449d-a1e0-bb495b728856 timestamp=2024-04-15 03:13:59 client disconnected ravcxOTIfoOjJZiv-e9xs WRN app is not running | meta={"status":"error"} module=gateway submodule= method=requestHandler app=main reqId=020b4b01-49e2-4af4-b680-05a0029d0b67 timestamp=2024-04-15 03:30:09 ERR Collection model roles has no primary key attribute | meta={"error":{"status":503,"message":"Collection model roles has no primary key attribute","code":"APP_ERROR","command":{"name":"start"},"maintaining":true}} module=gateway submodule= method=responseErrorWithCode app=main reqId=c358ad69-19b5-46cd-98eb-929da790364b timestamp=2024-04-15 03:30:09 new client connected ZswavY0BVM1OXWDFHLj_D client tags: app#main

Version

18.20.2

How To Reproduce

As above, launch new container, error presents upon start.

@Decapitares
Copy link

I have the same problem with mysql, it created the tables and the primary key is as it should be.

@Jackxwb
Copy link

Jackxwb commented May 28, 2024

The same issue occurred with the Docker+MySQL I used
(I am using the baota panel in MySQL, and I can see that many tables have been created.)
Docker error log:

client disconnected YvqEMwj_l-bHEc9DrK8-M
WRN app is not running | meta={"status":"error"} module=gateway submodule= method=requestHandler app=main reqId=1b78da36-981c-4e8d-8c37-17d225e6b555 dataSourceKey=main timestamp=2024-05-28 02:50:45
ERR Collection model roles has no primary key attribute | meta={"error":{"status":503,"message":"Collection model roles has no primary key attribute","code":"APP_ERROR","command":{"name":"start"},"maintaining":true}} module=gateway submodule= method=responseErrorWithCode app=main reqId=b408ab09-8aef-4fc8-aa85-6295244a275b dataSourceKey=main timestamp=2024-05-28 02:50:45

new client connected PpToxihV_LtTwmreGWCdB
client tags: app#main
yarn run v1.22.19
$ nocobase create-nginx-conf
Done in 8.53s.
nginx started
yarn run v1.22.19
$ nocobase start --quickstart
2024-05-28T02:51:23: PM2 log: Launching in no daemon mode
2024-05-28T02:51:23: PM2 log: App [index:0] starting in -fork mode-
2024-05-28T02:51:23: PM2 log: App [index:0] online
Gateway IPC Server running at /app/nocobase/storage/gateway.sock
Gateway HTTP Server running at http://0.0.0.0:13000/
INF add app main into supervisor | meta={} module=application submodule=supervisor method=addApp app=main reqId=685cafa0-5f0c-42ed-90d6-9287758d94c6 dataSourceKey=main timestamp=2024-05-28 02:52:03
new client connected 5vpkIkD86Jb07bRdmvRE0
client tags: app#main
INF connection has been established successfully. | meta={} module=database submodule= method=auth app=main reqId=685cafa0-5f0c-42ed-90d6-9287758d94c6 dataSourceKey=main timestamp=2024-05-28 02:52:03
INF upgrading... | meta={} module=application submodule= method= app=main reqId=685cafa0-5f0c-42ed-90d6-9287758d94c6 dataSourceKey=main timestamp=2024-05-28 02:52:03
INF run upgrade | meta={} module=application submodule= method= app=main reqId=685cafa0-5f0c-42ed-90d6-9287758d94c6 dataSourceKey=main timestamp=2024-05-28 02:52:03
INF update built-in plugins | meta={} module=nocobase submodule= method= app=main reqId=685cafa0-5f0c-42ed-90d6-9287758d94c6 dataSourceKey=main timestamp=2024-05-28 02:52:03
INF run upgrade | meta={} module=application submodule= method= app=main reqId=685cafa0-5f0c-42ed-90d6-9287758d94c6 dataSourceKey=main timestamp=2024-05-28 02:52:17
INF restarting... | meta={} module=application submodule= method= app=main reqId=685cafa0-5f0c-42ed-90d6-9287758d94c6 dataSourceKey=main timestamp=2024-05-28 02:52:19
INF app.reload() | meta={} module=application submodule= method=load app=main reqId=685cafa0-5f0c-42ed-90d6-9287758d94c6 dataSourceKey=main timestamp=2024-05-28 02:52:20
ERR Collection model roles has no primary key attribute | stack=Error: Collection model roles has no primary key attribute
    at _BelongsToManyField.bind (/app/nocobase/node_modules/@nocobase/database/lib/fields/belongs-to-many-field.js:116:13)
    at _Collection.<anonymous> (/app/nocobase/node_modules/@nocobase/database/lib/collection.js:629:13)
    at _Collection.emit (node:events:517:28)
    at _Collection.emit (node:domain:489:12)
    at _Collection.setField (/app/nocobase/node_modules/@nocobase/database/lib/collection.js:285:10)
    at EnsureAtomicity.descriptor.value (/app/nocobase/node_modules/@nocobase/database/lib/collection.js:68:29)
    at /app/nocobase/node_modules/@nocobase/plugin-data-source-main/dist/server/models/field.js:54:25
    at async model.load (/app/nocobase/node_modules/@nocobase/plugin-data-source-main/dist/server/models/field.js:52:19)
    at async model.loadFields (/app/nocobase/node_modules/@nocobase/plugin-data-source-main/dist/server/models/collection.js:128:7)
    at async CollectionRepository.load (/app/nocobase/node_modules/@nocobase/plugin-data-source-main/dist/server/repositories/collection-repository.js:131:7) meta={} module=application submodule= method= app=main reqId=685cafa0-5f0c-42ed-90d6-9287758d94c6 dataSourceKey=main timestamp=2024-05-28 02:52:21

web page
image

database
image

select version() from dual;
> 10.3.25-MariaDB-log

I use tools to analyze, and it seems that table structures all have their own primary keys
image

output SQL File>
nocobase.sql.txt


console Err:
image

image

compose.yaml
image

change APP_KEY reCreate Docker Container log

yarn run v1.22.19
$ nocobase create-nginx-conf
Done in 3.50s.
nginx started
yarn run v1.22.19
$ nocobase start --quickstart
2024-05-28T04:12:38: PM2 log: Launching in no daemon mode
2024-05-28T04:12:39: PM2 log: App [index:0] starting in -fork mode-
2024-05-28T04:12:39: PM2 log: App [index:0] online
Gateway IPC Server running at /app/nocobase/storage/gateway.sock
Gateway HTTP Server running at http://0.0.0.0:13000/
INF add app main into supervisor | meta={} module=application submodule=supervisor method=addApp app=main reqId=6d03a78d-2d96-465a-900b-ccb04e9b3c14 dataSourceKey=main timestamp=2024-05-28 04:13:32
INF connection has been established successfully. | meta={} module=database submodule= method=auth app=main reqId=6d03a78d-2d96-465a-900b-ccb04e9b3c14 dataSourceKey=main timestamp=2024-05-28 04:13:32
INF upgrading... | meta={} module=application submodule= method= app=main reqId=6d03a78d-2d96-465a-900b-ccb04e9b3c14 dataSourceKey=main timestamp=2024-05-28 04:13:33
INF run upgrade | meta={} module=application submodule= method= app=main reqId=6d03a78d-2d96-465a-900b-ccb04e9b3c14 dataSourceKey=main timestamp=2024-05-28 04:13:34
INF update built-in plugins | meta={} module=nocobase submodule= method= app=main reqId=6d03a78d-2d96-465a-900b-ccb04e9b3c14 dataSourceKey=main timestamp=2024-05-28 04:13:34
WRN app is not running | meta={"status":"commanding"} module=gateway submodule= method=requestHandler app=main reqId=3170ed23-93b5-465b-92c5-262d612489f2 dataSourceKey=main timestamp=2024-05-28 04:13:46
ERR plugins loaded | meta={"error":{"status":503,"maintaining":true,"message":"plugins loaded","command":{"name":"start"},"code":"APP_COMMANDING"}} module=gateway submodule= method=responseErrorWithCode app=main reqId=7cd2a160-4beb-43c4-8510-45ad6f6cf119 dataSourceKey=main timestamp=2024-05-28 04:13:46
new client connected cBL_KuyQImUUvSVsje1GW
client tags: app#main
INF run upgrade | meta={} module=application submodule= method= app=main reqId=6d03a78d-2d96-465a-900b-ccb04e9b3c14 dataSourceKey=main timestamp=2024-05-28 04:13:57
INF restarting... | meta={} module=application submodule= method= app=main reqId=6d03a78d-2d96-465a-900b-ccb04e9b3c14 dataSourceKey=main timestamp=2024-05-28 04:14:01
INF app.reload() | meta={} module=application submodule= method=load app=main reqId=6d03a78d-2d96-465a-900b-ccb04e9b3c14 dataSourceKey=main timestamp=2024-05-28 04:14:01
ERR Collection model roles has no primary key attribute | stack=Error: Collection model roles has no primary key attribute
    at _BelongsToManyField.bind (/app/nocobase/node_modules/@nocobase/database/lib/fields/belongs-to-many-field.js:116:13)
    at _Collection.<anonymous> (/app/nocobase/node_modules/@nocobase/database/lib/collection.js:629:13)
    at _Collection.emit (node:events:517:28)
    at _Collection.emit (node:domain:489:12)
    at _Collection.setField (/app/nocobase/node_modules/@nocobase/database/lib/collection.js:285:10)
    at EnsureAtomicity.descriptor.value (/app/nocobase/node_modules/@nocobase/database/lib/collection.js:68:29)
    at /app/nocobase/node_modules/@nocobase/plugin-data-source-main/dist/server/models/field.js:54:25
    at async model.load (/app/nocobase/node_modules/@nocobase/plugin-data-source-main/dist/server/models/field.js:52:19)
    at async model.loadFields (/app/nocobase/node_modules/@nocobase/plugin-data-source-main/dist/server/models/collection.js:128:7)
    at async CollectionRepository.load (/app/nocobase/node_modules/@nocobase/plugin-data-source-main/dist/server/repositories/collection-repository.js:131:7) meta={} module=application submodule= method= app=main reqId=6d03a78d-2d96-465a-900b-ccb04e9b3c14 dataSourceKey=main timestamp=2024-05-28 04:14:02

@zhouyanliang
Copy link
Contributor

Hi team. I am very new to Nocobase, so my apologies if I have missed something basic. Using Portainer, I created a nocobase container and was able to use it. However, it was completely default with no env variables, so nothing was persistent. I have since created a contaner for MariaDB and then declared env variables for nocobase. However, upon starting the container I see 'App error - Collection model roles has no primary key attribute' error in the web interface.
The data base connection is working because tables have been created. Not sure what else I have missed.
The log file also has these entries:

You are using MariaDB but DB_DIALECT=mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants