chat throws error with too many messages
Splitting this from #1215 (closed) because that's something different and probably more serious.
The chat throws an error if there are more than 20 messages, which forces pagination. Here's what's on the server:
error: select "messages"."id" as "id", "messages"."user_id" as "user_id", "messages"."channel_id" as "channel_id", "messages"."created" as "created", "messages"."updated" as "updated", "messages"."content" as "content", "user"."id" as "user:id", "user"."created" as "user:created", "user"."updated" as "user:updated", "user"."admin" as "user:admin", "user"."email" as "user:email", "user"."username" as "user:username", "user"."password_hash" as "user:password_hash", "user"."teams" as "user:teams", "user"."password_reset_token" as "user:password_reset_token", "user"."password_reset_timestamp" as "user:password_reset_timestamp", "user"."type" as "user:type", "user"."profile_picture" as "user:profile_picture", "user"."online" as "user:online", "user"."last_online" as "user:last_online" from "messages" left join "users" as "user" on "user"."id" = "messages"."user_id" where "channel_id" = $1 and "created" < $2 order by "created" desc limit $3 - column reference "created" is ambiguous name=DBError, length=113, name=error, severity=ERROR, code=42702, detail=undefined, hint=undefined, position=895, internalPosition=undefined, internalQuery=undefined, where=undefined, schema=undefined, table=undefined, column=undefined, dataType=undefined, constraint=undefined, file=parse_relation.c, line=694, routine=scanRTEForColumn, originalStack=error: select "messages"."id" as "id", "messages"."user_id" as "user_id", "messages"."channel_id" as "channel_id", "messages"."created" as "created", "messages"."updated" as "updated", "messages"."content" as "content", "user"."id" as "user:id", "user"."created" as "user:created", "user"."updated" as "user:updated", "user"."admin" as "user:admin", "user"."email" as "user:email", "user"."username" as "user:username", "user"."password_hash" as "user:password_hash", "user"."teams" as "user:teams", "user"."password_reset_token" as "user:password_reset_token", "user"."password_reset_timestamp" as "user:password_reset_timestamp", "user"."type" as "user:type", "user"."profile_picture" as "user:profile_picture", "user"."online" as "user:online", "user"."last_online" as "user:last_online" from "messages" left join "users" as "user" on "user"."id" = "messages"."user_id" where "channel_id" = $1 and "created" < $2 order by "created" desc limit $3 - column reference "created" is ambiguous
at Parser.parseErrorMessage (/home/node/app/node_modules/pg-protocol/dist/parser.js:278:15)
at Parser.handlePacket (/home/node/app/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/home/node/app/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/home/node/app/node_modules/pg-protocol/dist/index.js:10:42)
at Socket.emit (events.js:314:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:272:9)
at Socket.Readable.push (_stream_readable.js:213:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23), client=postgres
info: ::ffff:172.18.0.1 - - [20/Feb/2023:13:32:27 +0000] "POST /graphql HTTP/1.1" 200 130 "https://kotahidev.cloud68.co/kotahi/admin/manuscripts" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
This looks a lot like a GET_MESSAGES
query in https://gitlab.coko.foundation/kotahi/kotahi/-/blob/main/app/components/component-chat/src/MessageContainer.js is failing. Server end is https://gitlab.coko.foundation/kotahi/kotahi/-/blob/main/server/model-message/src/graphql.js#L23
On Kotahi Dev, this is replicable on the manuscripts page, which has more than 20 messages; an error pops up when you click "Show previous messages" at the top of the chat when it's trying to run this query. On a fresh install of Kotahi, you can make this happen by adding 20 messages to any chat.