hoarder-app / hoarder

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
https://hoarder.app
GNU Affero General Public License v3.0
2.25k stars 74 forks source link

SqliteError: FOREIGN KEY constraint failed when trying to add bookmark #245

Closed arminus closed 6 days ago

arminus commented 1 week ago

Tried to set this up with docker compose on a Pi4, but I'm getting this when trying to add a bookmark:

SqliteError: FOREIGN KEY constraint failed
    at w.values (/app/apps/web/.next/server/chunks/917.js:51:42087)
    ... 3 lines matching cause stack trace ...
    at QueryPromise.then (/app/apps/web/.next/server/chunks/917.js:51:45895) {
  code: 'INTERNAL_SERVER_ERROR',
  name: 'TRPCError',
  [cause]: SqliteError: FOREIGN KEY constraint failed
      at w.values (/app/apps/web/.next/server/chunks/917.js:51:42087)
      at w.all (/app/apps/web/.next/server/chunks/917.js:51:41676)
      at QueryPromise.all (/app/apps/web/.next/server/chunks/917.js:51:70800)
      at QueryPromise.execute (/app/apps/web/.next/server/chunks/917.js:51:70923)
      at QueryPromise.then (/app/apps/web/.next/server/chunks/917.js:51:45895) {
    code: 'SQLITE_CONSTRAINT_FOREIGNKEY'
  }
}

a data/db.db is created and looks "sane" (i.e. it has some tables)

Here's my docker-compose.yml:

version: "3"
services:
  web:
    image: ghcr.io/hoarder-app/hoarder-web:${HOARDER_VERSION:-release}
    restart: unless-stopped
    volumes:
      - ./data:/data
    ports:
      - 3078:3000
    env_file:
      - .env
    environment:
      REDIS_HOST: redis
      MEILI_ADDR: http://meilisearch:7700
      DATA_DIR: /data
  redis:
    image: redis:7.2-alpine
    restart: unless-stopped
    volumes:
      - ./redis:/data
  chrome:
    image: gcr.io/zenika-hub/alpine-chrome:123
    restart: unless-stopped
    command:
      - --no-sandbox
      - --disable-gpu
      - --disable-dev-shm-usage
      - --remote-debugging-address=0.0.0.0
      - --remote-debugging-port=9222
      - --hide-scrollbars
  meilisearch:
    image: getmeili/meilisearch:v1.6
    restart: unless-stopped
    env_file:
      - .env
    environment:
      MEILI_NO_ANALYTICS: "true"
    volumes:
      - ./meilisearch:/meili_data
  workers:
    image: ghcr.io/hoarder-app/hoarder-workers:${HOARDER_VERSION:-release}
    restart: unless-stopped
    volumes:
      - ./data:/data
    env_file:
      - .env
    environment:
      REDIS_HOST: redis
      MEILI_ADDR: http://meilisearch:7700
      BROWSER_WEB_URL: http://chrome:9222
      DATA_DIR: /data
      # OPENAI_API_KEY: ...
    depends_on:
      - web

env HOARDER_VERSION=release

MohamedBassem commented 6 days ago

That's weird. Did you try wiping the database file and restarting the web container?

arminus commented 6 days ago

Just did that, error is gone. Strange.

MohamedBassem commented 6 days ago

Yeah, first time seeing this as well.

ItsNoted commented 3 days ago

Getting the same error. Even after deleting the DB file and restarting. All I wanted to do was update the app and it had to break. Now it's gone lol.

Even trying a fresh install it wont budge.

ItsNoted commented 3 days ago

Strange. I spun up a new container and reinstalled it and it works now. It must have been saving data that was not mounted somewhere. That was weird.