civitai / civitai

A repository of models, textual inversions, and more
https://civitai.com
Apache License 2.0
6.21k stars 617 forks source link

[Bug]: CLICKHOUSE_TRACKER_URL is unvaild #544

Open JonSmall opened 1 year ago

JonSmall commented 1 year ago

What happened?

npm run dev

CLICKHOUSE_TRACKER_URL is unvaild

why use CLICKHOUSE_TRACKER_URL instead

for (const key of Object.keys(_serverEnv.data)) { error - (api)\src\env\server.mjs (13:8) @ eval error - Error: Invalid environment variables at eval (webpack-internal:///(api)/./src/env/server.mjs:19:11) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) 11 | if (!_serverEnv.success) { 12 | console.error('❌ Invalid environment variables:\n', ...formatErrors(_serverEnv.error.format()));

13 | throw new Error('Invalid environment variables'); | ^

Steps to reproduce the problem

git check git pull npm install npm run dev

What should have happened?

show website

What platforms do you use to access the site?

No response

What browsers do you use to access the site?

No response

Additional information, context and logs

No response

JonSmall commented 1 year ago

is there any stable code branch ? I use the main branch right now, lots of bugs , maybe someone merge branch , make some mistakes.

for example:

1.click your profile

show 404 The page you are looking for doesn't exist

2. upload a model

Unhandled Runtime Error TRPCClientError: Invalid prisma.modelVersion.create() invocation: Foreign key constraint failed on the field: ModelVersion_modelId_fkey (index)

3. cannot find my upload model page

4. init sql error

Error: P3006

Migration 20230523091547_ failed to apply cleanly to the shadow database. Error: db error: ERROR: cannot drop table "ModelRank" because other objects depend on it DETAIL: view "ImageResourceHelper" depends on table "ModelRank" view "PostResourceHelper" depends on view "ImageResourceHelper" view "UserStat" depends on table "ModelRank" view "UserRank_Live" depends on view "UserStat" HINT: Use DROP ... CASCADE to drop the dependent objects too. 0: sql_schema_connector::validate_migrations with namespaces=None at schema-engine\connectors\sql-schema-connector\src\lib.rs:309 1: schema_core::state::DevDiagnostic at schema-engine\core\src\state.rs:266

etc.

JustMaier commented 1 year ago

Hi @JonSmall we haven't done a great job of keeping the database seeding script or the example env file up to date since we've been moving fast to add new features and the team usually operates with a shared set of environment variables and dev database. I apologize for the difficulties that presents when trying to pick up and run the codebase.

We're planning to migrate to a different ORM in the future and as part of that flatten the migration history. I believe that will solve the problem that you mentioned here. We'll also update the example env and ensure that things tied to internal operations of the site like ClickHouse remain optional.

billcai commented 1 year ago

Hi @JustMaier and team, thanks for the great work. Would it be possible for a schema dump (no data) in the mean time, with any sensitive data redacted? This would help to address several bug reports related to db issues.

hassanRsiddiqi commented 1 year ago

@billcai were you able to fix this issue? If yes can you please share? I am encountering the exact issue.

JustMaier commented 1 year ago

@hassanRsiddiqi the CLICKHOUSE_TRACKER_URL has been updated to be an optional variable. Are you still having trouble with it on the latest version of main?

hassanRsiddiqi commented 1 year ago

yes, I had the issue, I resolve it after providing the click house details. Screen Shot 2023-07-06 at 12 11 00 AM

hassanRsiddiqi commented 1 year ago

Now I am facing this issue, I am stuck on it, and don't know how to fix. Screen Shot 2023-07-06 at 12 11 38 AM

mwmw7 commented 11 months ago

image

NicksonYap commented 11 months ago

Solution is to use older commit: https://github.com/civitai/civitai/commit/f5687d449f1be6200a2b209c38a04a0b52636815

Before these environment variables were introduced

In .env we can comment out CLICKHOUSE_TRACKER_URL and SCHEDULER_ENDPOINT to avoid that error, however it doesn't work for ORCHESTRATOR_ENDPOINT because:

this line is enforcing ORCHESTRATOR_ENDPOINT and ORCHESTRATOR_ACCESS_TOKEN to be required in orchestrator.caller.ts, although in schema.mjs it has been made optional

https://github.com/civitai/civitai/blob/bebed7ada44a1167d298403bbc01cbfa21941b4c/src/server/http/orchestrator/orchestrator.caller.ts#L13

  static getInstance(): OrchestratorCaller {
    if (!env.ORCHESTRATOR_ENDPOINT) throw new Error('Missing ORCHESTRATOR_ENDPOINT env');
    if (!env.ORCHESTRATOR_ACCESS_TOKEN) throw new Error('Missing ORCHESTRATOR_ACCESS_TOKEN env');
//...

related: https://github.com/civitai/civitai/issues/566#issuecomment-1614760791 @manuelurenah

zRich commented 4 months ago

I am facing the same issue, any update?

sovos15 commented 1 month ago

Should be closed if fixed by Environment fixes #1283