PhlexPlexico / G5API

An express API for CS2 Servers using MatchZy and PugSharp to record and manage matches.
MIT License
97 stars 31 forks source link

[BUG] Adding workshop map to season causes 500 on season load #237

Closed JesusWithPants closed 1 year ago

JesusWithPants commented 1 year ago

Describe the bug Adding workshop map to season causes HTTP 500 on season load.

0|G5API  | SyntaxError: Unexpected number in JSON at position 123

0|G5API  |     at JSON.parse (<anonymous>)

0|G5API  |     at file:///Get5API/routes/seasons.js:100:38

0|G5API  |     at runMicrotasks (<anonymous>)

0|G5API  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)

0|G5API  | GET /seasons 500 3.068 ms - 68

image

To Reproduce Steps to reproduce the behavior:

  1. Create a season with including a workshop map (in this case workshop\1542127528\de_cbble)
  2. On save - no seasons are loaded anymore.

Repeatable on any browser (as this seems to be a backend error)

CSGO Server info Dathost CSGO server instance

Host info Running on a VPS as docker instance, spawned by docker-composer file:

version: "3.7"

networks:
  get5:
    external: true

services:
  redis:
    image: redis:6
    command: redis-server --requirepass ${redispassword}
    container_name: get5redis
    networks:
      - get5
    restart: always

  get5db:
    image: mariadb
    container_name: get5db
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=${sqlrootpassword}
      - MYSQL_DATABASE=get5
      - MYSQL_USER=get5
      - MYSQL_PASSWORD=${sqlpassword}
      - MYSQL_CHARSET=utf8mb4
      - MYSQL_COLLATION=utf8mb4_general_ci
#    ports:
#      - "3306:3306"
    expose:
      - 3306
    networks:
      - get5

  g5api:
    image: ghcr.io/phlexplexico/g5api:latest
    depends_on:
      - get5db
    container_name: G5API
    volumes: 
      - redisVol:/Get5API/public
#    expose:
#      - 3301
    environment:
      - NODE_ENV=production
      - PORT=3301
      - HOSTNAME=${hostname}
      - DBKEY=${dbkey}
      - STEAMAPIKEY=${steamkey}
      - SHAREDSECRET=${sharedsecret}
      - CLIENTHOME=${home}
      - APIURL=${apiurl}
      - SQLUSER=get5
      - SQLPASSWORD=${sqlpassword}
      - SQLPORT=3306
      - DATABASE=get5
      - SQLHOST=get5db
      - ADMINS=${admins}
      - SUPERADMINS=${superadmins}
      - REDISURL=redis://:${redispassword}@redis:6379
      - REDISTTL=86400
      - USEREDIS=true
      - UPLOADDEMOS=true
      - LOCALLOGINS=false
    restart: always
    networks:
      - get5
    labels:      
      - "traefik.enable=true"
      - "traefik.http.routers.get5api.rule=Host(`get5.domain.tld`) && PathPrefix(`/api`)"
      - "traefik.http.routers.get5api.entrypoints=websecure"
      - "traefik.http.routers.get5api.tls=true"
      - "traefik.http.routers.get5api.tls.certresolver=letsencrypt"
      - "traefik.http.routers.get5api.middlewares=get5api_path@docker"
#      - "traefik.http.routers.get5api.middlewares=get5api_path@docker,get5api_head@docker"
      - "traefik.http.middlewares.get5api_path.replacepathregex.regex=^/api/(.*)$$"
      - "traefik.http.middlewares.get5api_path.replacepathregex.replacement=/$$1"
#      - "traefik.http.middlewares.get5api_head.headers.hostsProxyHeaders=true"

  g5v:
    image: ghcr.io/phlexplexico/g5v:latest
    depends_on: 
      - g5api
    container_name: G5V-Front-End
    restart: always
    networks:
      - get5
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.get5.rule=Host(`get5.domain.tld`)"
      - "traefik.http.routers.get5.entrypoints=websecure"
      - "traefik.http.routers.get5.tls=true"
      - "traefik.http.routers.get5.tls.certresolver=letsencrypt"

volumes:
  redisVol:
    external: false
PhlexPlexico commented 1 year ago

Would you mind sending me the database record for that seasons' cvars?

SELECT * FROM season_cvar WHERE season_id = X

Where your season ID is the X.

Thanks!

PhlexPlexico commented 1 year ago

I believe this is just the JSON parser failing due to the backslash.

As an aside, get5 doesn't really support workshop maps currently, I believe it's a bit flaky as of right now - https://github.com/splewis/get5/issues/755

So just a heads up about that as well :)

JesusWithPants commented 1 year ago
id season_id cvar_name cvar_value
1 1 min_players_to_ready 5
2 1 min_spectators_to_ready 1
3 1 players_per_team 5
4 1 maps_to_win 1
5 1 skip_veto 0
6 1 map_pool de_inferno de_ancient de_nuke de_mirage de_overpass de_dust2 de_vertigo de_cache workshop\1542127528\de_cbble
7 1 spectators
8 1 side_type standard
9 1 map_sides

Ran a test-match and it worked with said map, so no problems running it there, its more that the season data gets borked and refuses to load any season :/

PhlexPlexico commented 1 year ago

For a temp workaround until I can fix this just do the following DB update query:

UPDATE season_cvar SET cvar_value = "de_inferno de_ancient de_nuke de_mirage de_overpass de_dust2 de_vertigo de_cache workshop\\1542127528\\de_cbble" WHERE id = 6;

That should fix the loading issue, but the API should be replacing those as well, just in the post and update calls do an additional replace for quotes, and forward slashes.

PhlexPlexico commented 1 year ago

Alright, it's been updated in the master branch as well, so if you wait for the image to build this should be fixed for future updates :) but that SQL will fix your database as well.

docker exec -it get5db sh

Login to your db and then call that update command.

JesusWithPants commented 1 year ago

Checked latest build - works as expected now.