umami-software / api-client

API client for Umami Analytics
MIT License
14 stars 11 forks source link

umami api client test ko with docker umami version 2.13.3 #17

Open boly38 opened 2 months ago

boly38 commented 2 months ago

Hi, https://github.com/boly38/action-umami-report/issues/59 I'm trying to play basis example (ex. I first would like to list websites)

env

export UMAMI_API_CLIENT_USER_ID=admin
export UMAMI_API_CLIENT_PASSWORD=xxx-replace-by-admin-password-here
export UMAMI_API_CLIENT_SECRET=xxx-replace-by-app-secret-set-in-docker-compose
export UMAMI_API_CLIENT_ENDPOINT=https://myumami.example.fr/api

node

import {getClient} from '@umami/api-client';

const umamiUsername = process.env.UMAMI_API_CLIENT_USER_ID;
const umamiPassword = process.env.UMAMI_API_CLIENT_PASSWORD;
let client;
const getMeFixed = false;
{
    client = getClient();
    const {ok, data, status, error} = await client.login(umamiUsername, umamiPassword);
    console.log(`login: ${JSON.stringify({ok, data, status, error}, null, 2)}`);
}
if (getMeFixed) {
    const {ok, data, status, error} = await client.getMe();
    console.log(`getMe: ${JSON.stringify({ok, data, status, error}, null, 2)}`);
}
{
    const {ok, data, status, error} = await client.getWebsites();
    console.log(`getWebsites: ${JSON.stringify({ok, data, status, error}, null, 2)}`);
}

result

login: {
  "ok": true,
  "data": {
    "token": "==REDATED==",
    "user": {
      "id": "==REDATED==",
      "username": "admin",
      "role": "admin",
      "createdAt": "2024-07-12T15:52:00.340Z",
      "isAdmin": true
    }
  },
  "status": 200
}
getWebsites: {
  "ok": false,
  "status": 504,
  "error": "<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body>\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n<hr><center>nginx</center
>\r\n</body>\r\n</html>\r\n"
}

but I got 504 error with server side error logs :

PrismaClientKnownRequestError:
Invalid `prisma.user.findUnique()` invocation:

Inconsistent column data: Error creating UUID, invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `m` at 3
    at _n.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:7749)
    at _n.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/library.js:121:7057)
    at _n.request (/app/node_modules/@prisma/client/runtime/library.js:121:6741)
    at async l (/app/node_modules/@prisma/client/runtime/library.js:130:9355)
    at async /app/.next/server/chunks/405.js:1:17597 {
  code: 'P2023',
  clientVersion: '5.17.0',
  meta: {
    modelName: 'User',
    message: 'Error creating UUID, invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `m` at 3'
  }
}

NB: it was the same kind of error for getMe use case.

this issue and error logs are close to umami-software/umami/issues/1964

I just try to create a !admin new user and switch env to use this new creds, login is ok but I got same issue for the getWebsites step .. :'(

any help / hint appreciated regards

boly38 commented 2 months ago