[GH-ISSUE #3973] [BUG] Discord alerts send invalid JSON when sending servername #2565

Closed
opened 2026-02-27 03:03:47 +03:00 by kerem · 6 comments
Owner

Originally created by @Arthur-D on GitHub (Aug 30, 2022).
Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/3973

User Story

As a server administrator, I want Discord alerts to work without hassle for everyone so that they don't give up on getting alerts.

Basic info

  • Distro: [Ubuntu 18.04.6]
  • Game: [Minecraft]
  • Command: [test-alert]
  • LinuxGSM version: [v22.1.0]

Further Information

Sending Discord alerts fails with a parse error, listed in the To Reproduce section of this bug report. I managed to work around it by changing line 21 in lgsm/functions/alert_discord.sh from
"title": "${servername}", to
"title": "Minecraft", and thus exchanging the variable for a static name.

At first I thought the "invalid escape" bit in the error message meant I couldn't have a space in my Discord server name, so I changed its name from "Multiplayer Minecraft" to just "Minecraft" and made a new webhook, just in case. But it did not resolve the issue, so I had to go with the above workaround instead.

To Reproduce

Steps to reproduce the behaviour:

  1. In my instance config lgsm/config-lgsm/mcserver/mcserver.cfg I added the Notification Alerts section from the template lgsm/config-lgsm/mcserver/_default.cfg
  2. I followed https://docs.linuxgsm.com/alerts/discord but added the URL to my instance mcserver.cfg instead of common.cfg
  3. I ran ./mcserver test-alert
  4. See error:
    [ .... ] Sending Alert mcserver: Sending Discord alertparse error: Invalid escape at line 11, column 40 [ FAIL ] Sending Alert mcserver: Sending Discord alert: {"code": 50109, "message": "The request body contains invalid JSON."}

Expected behaviour

For the Discord alert to work without having to exchange a variable for a static servername.

Originally created by @Arthur-D on GitHub (Aug 30, 2022). Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/3973 ## User Story As a server administrator, I want Discord alerts to work without hassle for everyone so that they don't give up on getting alerts. ## Basic info * **Distro:** [Ubuntu 18.04.6] * **Game:** [Minecraft] * **Command:** [test-alert] * **LinuxGSM version:** [v22.1.0] ## Further Information Sending Discord alerts fails with a parse error, listed in the To Reproduce section of this bug report. I managed to work around it by changing line 21 in lgsm/functions/alert_discord.sh from ` "title": "${servername}",` to ` "title": "Minecraft",` and thus exchanging the variable for a static name. At first I thought the "invalid escape" bit in the error message meant I couldn't have a space in my Discord server name, so I changed its name from "Multiplayer Minecraft" to just "Minecraft" and made a new webhook, just in case. But it did not resolve the issue, so I had to go with the above workaround instead. ## To Reproduce Steps to reproduce the behaviour: 1. In my instance config lgsm/config-lgsm/mcserver/mcserver.cfg I added the Notification Alerts section from the template lgsm/config-lgsm/mcserver/_default.cfg 2. I followed https://docs.linuxgsm.com/alerts/discord but added the URL to my instance mcserver.cfg instead of common.cfg 3. I ran ./mcserver test-alert 4. See error: `[ .... ] Sending Alert mcserver: Sending Discord alertparse error: Invalid escape at line 11, column 40 [ FAIL ] Sending Alert mcserver: Sending Discord alert: {"code": 50109, "message": "The request body contains invalid JSON."}` ## Expected behaviour For the Discord alert to work without having to exchange a variable for a static servername.
Author
Owner

@malro57 commented on GitHub (Oct 7, 2022):

Have the same behavior here just after a fresh install of Memories Of Mars server. By the way my other server configured in the past still working as expected with test-alert.

<!-- gh-comment-id:1271679340 --> @malro57 commented on GitHub (Oct 7, 2022): Have the same behavior here just after a fresh install of Memories Of Mars server. By the way my other server configured in the past still working as expected with test-alert.
Author
Owner

@Zxurian commented on GitHub (Nov 30, 2022):

This appears to still be happening, although I'm getting the error on a different line.

vaulthunters@minecraft-dedicated:/mnt/minecraft/vaulthunters$ ./mcserver test-alert
[ .... ] Sending Alert mcserver: UNAVAILABLEgrep: (standard input): binary file matches
[ WARN ] Sending Alert mcserver: More Info not enabled
[ .... ] Sending Alert mcserver: Sending Discord alertparse error: Invalid escape at line 11, column 120
[ FAIL ] Sending Alert mcserver: Sending Discord alert: {"code": 50109, "message": "The request body contains invalid JSON."}

I tried commenting out displayip value, however still got the same error with only discordwebhook defined within secrets-common.cfg

Edit:
Did some testing. I have 3 diffrent game servers with LGSM. Ark, Vlaheim, & Minecraft. The Ark & Valheim servers were both able to send discord alerts without issue. The Minecraft server will not and produces the Errors.

Of note - I am running two minecraft installations on the same server, and the Invalid escape is at different points in the code depending on the installation.
Installation 1 - user mcserver, installdir /mnt/minecraft/minecraftserver/, error is at line 11, column 44
Installation 2 - user vaulthunters, installdir /mnt/minecraft/vaulthunters/, error is at line 11, column 120

<!-- gh-comment-id:1331592724 --> @Zxurian commented on GitHub (Nov 30, 2022): This appears to still be happening, although I'm getting the error on a different line. ``` vaulthunters@minecraft-dedicated:/mnt/minecraft/vaulthunters$ ./mcserver test-alert [ .... ] Sending Alert mcserver: UNAVAILABLEgrep: (standard input): binary file matches [ WARN ] Sending Alert mcserver: More Info not enabled [ .... ] Sending Alert mcserver: Sending Discord alertparse error: Invalid escape at line 11, column 120 [ FAIL ] Sending Alert mcserver: Sending Discord alert: {"code": 50109, "message": "The request body contains invalid JSON."} ``` I tried commenting out `displayip` value, however still got the same error with only `discordwebhook` defined within `secrets-common.cfg` Edit: Did some testing. I have 3 diffrent game servers with LGSM. Ark, Vlaheim, & Minecraft. The Ark & Valheim servers were both able to send discord alerts without issue. The Minecraft server will not and produces the Errors. Of note - I am running two minecraft installations on the same server, and the Invalid escape is at different points in the code depending on the installation. Installation 1 - user `mcserver`, installdir `/mnt/minecraft/minecraftserver/`, error is at `line 11, column 44` Installation 2 - user `vaulthunters`, installdir `/mnt/minecraft/vaulthunters/`, error is at `line 11, column 120`
Author
Owner

@theroflcopterguy commented on GitHub (Jul 18, 2023):

You need to change the motd in the server properties, i had same issue and this fixed it!!

<!-- gh-comment-id:1639132754 --> @theroflcopterguy commented on GitHub (Jul 18, 2023): You need to change the motd in the server properties, i had same issue and this fixed it!!
Author
Owner

@egeexyz commented on GitHub (Aug 5, 2023):

You need to change the motd in the server properties, i had same issue and this fixed it!!

Can confirm this! I had a \ in the server title. Saw this post, removed it, and poof ~ it worked!

<!-- gh-comment-id:1666592802 --> @egeexyz commented on GitHub (Aug 5, 2023): > You need to change the motd in the server properties, i had same issue and this fixed it!! Can confirm this! I had a `\` in the server title. Saw this post, removed it, and poof ~ it worked!
Author
Owner

@dgibbs64 commented on GitHub (Oct 20, 2023):

Game server admins sometimes like to use all sorts of unusual characters for server name that can sometimes cause issues with being parsed in bash. \ is an example of this as in bash \ is an escape character. There isn't much I can really do as far as I can tell to get around this issue

<!-- gh-comment-id:1773466353 --> @dgibbs64 commented on GitHub (Oct 20, 2023): Game server admins sometimes like to use all sorts of unusual characters for server name that can sometimes cause issues with being parsed in bash. \ is an example of this as in bash \ is an escape character. There isn't much I can really do as far as I can tell to get around this issue
Author
Owner

@github-actions[bot] commented on GitHub (Oct 21, 2024):

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

<!-- gh-comment-id:2425308325 --> @github-actions[bot] commented on GitHub (Oct 21, 2024): This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Sign in to join this conversation.
No labels
Atomic
Epic
cannot reproduce
command: backup
command: console
command: debug
command: details
command: fast-dl
command: install
command: mods
command: monitor
command: post-details
command: restart
command: send
command: start
command: stop
command: update
command: update-lgsm
command: validate
command: wipe
distro: AlmaLinux
distro: Arch Linux
distro: CentOS
distro: Debian
distro: Fedora
distro: RedHat
distro: Rocky Linux
distro: Ubuntu
distro: openSUSE
engine: goldsrc
engine: source
game: 7 Days to Die
game: ARMA 3
game: Ark: Survival Evolved
game: Assetto Corsa
game: Avorion
game: BATTALION: Legacy
game: Barotrauma
game: Battalion 1944
game: Battlefield 1942
game: Black Mesa: Deathmatch
game: Blade Symphony
game: Call of Duty 2
game: Call of Duty 4
game: Call of Duty: United Offensive
game: Counter-Strike 1.6
game: Counter-Strike 2
game: Counter-Strike: Global Offensive
game: Counter-Strike: Source
game: Day of Infamy
game: Dayz
game: Death Match Classic
game: Don't Starve Together
game: ET: Legacy
game: Eco
game: Factorio
game: Factorio
game: Garry's Mod
game: Half-Life
game: Hurtword
game: Insurgecy
game: Insurgecy
game: Insurgency: Sandstorm
game: Just Cause 3
game: Killing Floor
game: Killing Floor 2
game: Left 4 Dead 2
game: Minecraft
game: Minecraft Bedrock
game: Mordhau
game: Multi Theft Auto
game: Mumble
game: Natural Selection 2
game: No More Room in Hell
game: Pavlov VR
game: Post Scriptum
game: Project Zomboid
game: Quake 3
game: QuakeWorld
game: Red Orchestra: Ostfront 41-45
game: Return to Castle Wolfenstein
game: Rising World
game: Rust
game: San Andreas Multiplayer
game: Satisfactory
game: Soldat
game: Soldier of Fortune 2
game: Squad
game: Squad 44
game: Starbound
game: Stationeers
game: Sven Co-op
game: Team Fortress 2
game: Teamspeak 3
game: Teeworlds
game: Terraria
game: The Front
game: Unreal Tournament 2004
game: Unreal Tournament 3
game: Unreal Tournament 99
game: Unturned
game: Valheim
game: Wurm Unlimited
game: Zombie Master Reborn
game: label missing
good first issue
help wanted
info: alerts
info: dependency
info: docker
info: docs
info: email
info: query
info: steamcmd
info: systemd
info: tmux
info: website
info: website
needs more info
outcome: duplicate
outcome: issue resolved
outcome: issue resolved
outcome: issue unresolved
outcome: pr accepted
outcome: pr rejected
outcome: unconfirmed
outcome: wontfix
outcome: wrong forum
potential-duplicate
priority
pull-request
type: bug
type: feature
type: feature
type: feature request
type: game server request
type: refactor
waiting response
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/LinuxGSM#2565
No description provided.