Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Error 500 on stats Api #1241

Closed
alex289 opened this issue Jun 28, 2022 · 10 comments
Closed

Error 500 on stats Api #1241

alex289 opened this issue Jun 28, 2022 · 10 comments

Comments

@alex289
Copy link

alex289 commented Jun 28, 2022

Hey, I use umami to get statistics of some websites but the Api is not working.

After getting an auth token from /api/auth/login (POST) I made a request to /api/website/{id}/stats but always got an error 500.
I tried it both with the token as bearer and as a cookie. (Cookies result was 401).

Am I using the api wrong or is this a bug?

@mikecao
Copy link
Collaborator

mikecao commented Jun 28, 2022

You shouldn't get a 500. That means something went wrong on your server. You'll have to check the logs.

@alex289
Copy link
Author

alex289 commented Jun 28, 2022

What logs exactly do you mean?

@mikecao
Copy link
Collaborator

mikecao commented Jun 28, 2022

Run yarn dev and view your console.

@thomaes8
Copy link

thomaes8 commented Jun 28, 2022

My problem is the same I think. Dev console:

error - (api)\pages\api\website\[id]\stats.js (46:37) @ eval
Cannot mix BigInt and other types, use explicit conversions
  44 |       obj[key] = {
  45 |         value: Number(metrics[0][key]) || 0,
> 46 |         change: Number(metrics[0][key] - prevPeriod[0][key]) || 0,
     |                                     ^
  47 |       };
  48 |       return obj;
  49 |     }, {});
error - TypeError: Do not know how to serialize a BigInt
error - TypeError: Do not know how to serialize a BigInt
error - TypeError: Do not know how to serialize a BigInt
error - TypeError: Do not know how to serialize a BigInt
error - TypeError: Do not know how to serialize a BigInt
error - TypeError: Do not know how to serialize a BigInt
error - TypeError: Do not know how to serialize a BigInt

@alex289
Copy link
Author

alex289 commented Jun 29, 2022

I got the error:

Invalid `prisma.$queryRaw()` invocation:
Failed to validate the query: `Assertion error: Nested JSON arguments are not supported.` at `Mutation.queryRaw.parameters`

@thomaes8
Copy link

My problem is diferent, I create new ticket

@mikecao
Copy link
Collaborator

mikecao commented Jun 29, 2022

@alex289 what parameters are you passing to the api?

@alex289
Copy link
Author

alex289 commented Jun 29, 2022

I tried multiple versions because the documentation was not helpful about the format. I tried this formats for start_at and end_at:
2022-06-28 01:00:00, 2022 06 28 and 01.06.2022

@alex289
Copy link
Author

alex289 commented Jun 29, 2022

I looked at the Vercel errors on these inputs:

[GET] /api/website/1/stats
11:49:53:41
2022-06-27T09:49:53.769Z	f481208f-2c14-4d75-a61d-85b7815c61bc	ERROR	PrismaClientKnownRequestError: Failed to validate the query: `Assertion error: Nested JSON arguments are not supported.` at `Mutation.queryRaw.parameters`
    at RequestHandler.request (/var/task/node_modules/@prisma/client/runtime/index.js:49022:15)
    at async Proxy._request (/var/task/node_modules/@prisma/client/runtime/index.js:49919:18)
    at async __WEBPACK_DEFAULT_EXPORT__ (/var/task/.next/server/pages/api/website/[id]/stats.js:137:25)
    at async Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:182:9)
    at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:386:9)
    at async Object.fn (/var/task/node_modules/next/dist/server/base-server.js:488:37)
    at async Router.execute (/var/task/node_modules/next/dist/server/router.js:228:32)
    at async NextNodeServer.run (/var/task/node_modules/next/dist/server/base-server.js:600:29)
    at async NextNodeServer.handleRequest (/var/task/node_modules/next/dist/server/base-server.js:307:20)
    at async Server.module.exports (/var/task/___next_launcher.cjs:29:9) {
  code: 'P2009',
  clientVersion: '3.15.2',
  meta: {
    query_validation_error: 'Assertion error: Nested JSON arguments are not supported.',
    query_position: 'Mutation.queryRaw.parameters'
  }
}
2022-06-27T09:49:53.780Z	f481208f-2c14-4d75-a61d-85b7815c61bc	ERROR	PrismaClientKnownRequestError: Failed to validate the query: `Assertion error: Nested JSON arguments are not supported.` at `Mutation.queryRaw.parameters`
    at RequestHandler.request (/var/task/node_modules/@prisma/client/runtime/index.js:49022:15)
    at async Proxy._request (/var/task/node_modules/@prisma/client/runtime/index.js:49919:18)
    at async __WEBPACK_DEFAULT_EXPORT__ (/var/task/.next/server/pages/api/website/[id]/stats.js:137:25)
    at async Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:182:9)
    at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:386:9)
    at async Object.fn (/var/task/node_modules/next/dist/server/base-server.js:488:37)
    at async Router.execute (/var/task/node_modules/next/dist/server/router.js:228:32)
    at async NextNodeServer.run (/var/task/node_modules/next/dist/server/base-server.js:600:29)
    at async NextNodeServer.handleRequest (/var/task/node_modules/next/dist/server/base-server.js:307:20)
    at async Server.module.exports (/var/task/___next_launcher.cjs:29:9) {
  code: 'P2009',
  clientVersion: '3.15.2',
  meta: {
    query_validation_error: 'Assertion error: Nested JSON arguments are not supported.',
    query_position: 'Mutation.queryRaw.parameters'
  }
}
RequestId: f481208f-2c14-4d75-a61d-85b7815c61bc Error: Runtime exited with error: exit status 1
Runtime.ExitError

@boly38
Copy link

boly38 commented Jul 2, 2022

@alex289

I tried multiple versions because...

Using developer console, you could inspect network exchange from umami portal to have an idea of what param (or param format) are expected for some umami API if documentation is not complete.

This way I find that start_at or end_at format is timestamp in milliseconds. (cf. #1252)

Btw I agree: the doc may be improved to add a sample

@umami-software umami-software locked and limited conversation to collaborators Jul 5, 2022
@mikecao mikecao converted this issue into discussion #1265 Jul 5, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants