Skip to content

500 Internal Server Error for Regular Users on /dashboard #154

@dawidmalina

Description

@dawidmalina

Hi,

When accessing http://localhost:3000/dashboard as an admin user, everything works as expected. However, when trying to access the same page as a regular user, the request fails with a 500 Internal Server Error.

Here is the relevant log output:

DrizzleQueryError: Failed query: select count(*) from "url" where ("url"."organization_id" = $1 and "url"."status" = $2 and "apikey"."user_id" = $3)
params: httplocalhost3000,blocked,MF3hFy6snG8whxoWB6VYNmPvjM8UYNjn
    at PostgresJsPreparedQuery.queryWithCache (file:///app/node_modules/drizzle-orm/pg-core/session.js:41:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async file:///app/node_modules/drizzle-orm/postgres-js/session.js:39:20
    at async load (file:///app/build/server/chunks/18-Ch-AvfkZ.js:63:27)
    at async fn (file:///app/build/server/index.js:2716:23)
    at async load_server_data (file:///app/build/server/index.js:2707:18)
    at async file:///app/build/server/index.js:4407:31 {
  query: 'select count(*) from "url" where ("url"."organization_id" = $1 and "url"."status" = $2 and "apikey"."user_id" = $3)',
  params: [
    'httplocalhost3000',
    'blocked',
    'MF3hFy6snG8whxoWB6VYNmPvjM8UYNjn'
  ],
  cause: PostgresError: missing FROM-clause entry for table "apikey"
      at ErrorResponse (file:///app/node_modules/postgres/src/connection.js:794:26)
      at handle (file:///app/node_modules/postgres/src/connection.js:480:6)
      at Socket.data (file:///app/node_modules/postgres/src/connection.js:315:9)
      at Socket.emit (node:events:508:28)
      at addChunk (node:internal/streams/readable:559:12)
      at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
      at Readable.push (node:internal/streams/readable:390:5)
      at TCP.onStreamRead (node:internal/stream_base_commons:189:23) {
    severity_local: 'ERROR',
    severity: 'ERROR',
    code: '42P01',
    position: '92',
    file: 'parse_relation.c',
    line: '3657',
    routine: 'errorMissingRTE'
  }
}

The dashboard should load successfully for regular users, just as it does for admin users.

Actual Behavior:
A 500 Internal Server Error is returned, and the logs show the query error mentioned above.

Could you please investigate this issue? Let me know if you need any additional information.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions