Yooooomi / your_spotify

Self hosted Spotify tracking dashboard
GNU General Public License v3.0
2.67k stars 109 forks source link

Duplicate Key Error in MongoDB During Import of streaming-history.json in Docker Container #312

Open xFrenchGamer73 opened 7 months ago

xFrenchGamer73 commented 7 months ago

Hi,

I'm facing an issue with a MongoDB instance running in a Docker container. The problem arises when I attempt to import data from a streaming-history.json file into the tracks collection of my your_spotify database. I'm encountering a duplicate key error as follows:

image

This error occurs specifically during the import process of the streaming-history.json file, causing data insertion failures due to a conflict with the id field, which is supposed to be unique.

I am seeking advice on how to handle this issue, especially considering it seems to be related to MongoDB's handling of unique indexes within a containerized environment. Any tips on managing duplicate keys during JSON data import, or on configuring MongoDB in Docker to avoid such conflicts, would be highly appreciated.

Thank you for your assistance!

xFrenchGamer73 commented 7 months ago

Compose file

version: "3"

services:
  server:
    image: yooooomi/your_spotify_server
    restart: always
    ports:
      - "8080:8080"
    links:
      - mongo
    depends_on:
      - mongo
    environment:
      API_ENDPOINT: http://192.168.1.2:8080 # This MUST be included as a valid URL in the spotify dashboard (see below)
      CLIENT_ENDPOINT: http://192.168.1.2:3000
      SPOTIFY_PUBLIC: 
      SPOTIFY_SECRET: 
  mongo:
    container_name: mongo
    image: mongo:6
    volumes:
      - ./your_spotify_db:/data/db

  web:
    image: yooooomi/your_spotify_client
    restart: always
    ports:
      - "3000:3000"
    environment:
      API_ENDPOINT: http://192.168.1.2:8080
Yooooomi commented 7 months ago

Hello! It seems related to my implementation of importing streaming history. If you don't mind sending your failing file to yooooomi_ on discord, it would be greatly appreciated and save me a bit of time. Also, are you importing normal history or extended one? Thanks a lot