Skip to content

fix(core): propagate archive extraction and copy failures - #5109

Merged
dgibbs64 merged 1 commit into
GameServerManagers:developfrom
guilherme-praca:fix/extract-failure-propagation
Oct 30, 2026
Merged

dgibbs64 merged 1 commit into
GameServerManagers:developfrom
guilherme-praca:fix/extract-failure-propagation

Conversation

@guilherme-praca

Copy link
Copy Markdown

Description

fn_dl_extract could print "OK" and return 0 without extracting anything:

  • An unsupported MIME type matched none of the branches, so the if returned 0.
  • In selective ZIP extraction (extractsrc set) the captured status came from rm -rf, hiding failures from unzip (e.g. extractsrc not in the archive) and from cp.

Changes:

  • Add an else branch that fails with Unsupported archive type: <mime>.
  • Chain unzip && cp inside the captured command, so either failure sets the exit code.
  • Remove the temp directory only after exitcode is captured, so cleanup cannot mask a failure.
  • Capture stderr (2>&1) of tar/unzip/cp, so the reason ends up in extractcmd and the script log instead of only on the terminal.
  • Update the function header comment (it did not mention xz).

Fixes #5048

Affected servers: all servers that download archives through fn_dl_extract (install, update and fix modules, e.g. ts3, mta, fctr, xnt, jk2, steamcmd bootstrap).

Type of change

  • Bug fix (a change which fixes an issue).
  • New feature (a change which adds functionality).
  • New Server (new server added).
  • Refactor (restructures existing code).
  • Chore (CI, workflows, tooling or other maintenance).
  • Comment update (typo, spelling, explanation, examples, etc).

Testing

  • Commands/tests run: sourced fn_dl_extract from develop and from this branch with stubbed print/log/exit functions and ran both against the same fixtures (tar.gz, tar.bz2, tar.xz, zip; truncated tar.xz and zip; plain text file; missing extractsrc for zip and tar.gz; read-only destination for selective zip). shellcheck -S warning lgsm/modules/core_dl.sh is clean.
  • Result:
case develop this PR
valid tar.gz / tar.bz2 / tar.xz / zip, full and selective OK, rc 0 OK, rc 0
truncated tar.xz / zip FAIL, rc 2 / 9 FAIL, rc 2 / 9 (error now in log)
unsupported type (text/plain) OK, rc 0, nothing extracted FAIL, rc 1
selective zip, extractsrc missing OK, rc 0 FAIL, rc 11
selective zip, cp fails OK, rc 0 FAIL, rc 1
selective tar.gz, extractsrc missing FAIL, rc 2 FAIL, rc 2

Temp directory is removed in every case. Also checked: a downloaded HTML error page (text/html) and a plain .tar now fail as unsupported.

  • Callers: every caller passes .tar.gz, .tar.bz2, .tar.xz or .zip (install_server_files, fix_, core_steamcmd, update_, and all 55 entries in mods_list.sh), so none relied on the old silent success. file is a required dependency in every distro CSV.

Failure propagation and exitbypass

  • Update path: fn_update_apply runs download and extraction in a subshell with exitbypass unset (command_update.sh), so a failed extraction stops the update.
  • Not changed here: when exitbypass is set, core_exit.sh returns instead of exiting, so the caller keeps going. One reachable case is command_update.sh → exitbypass=1 command_start.sh → check_steamcmd.sh → fn_install_steamcmd, which would continue to chmod +x steamcmd.sh after a failed extraction. This is the same for every core_exit.sh call in core_dl.sh, and a return 1 alone would not help because the callers do not check the return status, so I left it out of this PR. Happy to follow up if you want a specific approach.
  • Environment used (distro/version): Fedora 44, bash 5, GNU tar, unzip 6.0

Risk and rollback

  • Risk level: low. Successful extractions behave the same; only paths that already failed silently now stop with an error. One intended change: in selective ZIP extraction (jk2, xnt) an unzip warning (exit 1) now fails, as it already did for full ZIP extraction. On success, tar/unzip warnings are no longer printed live.
  • Rollback plan: revert this commit.

Breaking changes

  • No breaking changes.
  • Breaking changes included (describe below).

Documentation

Checklist

  • This pull request links to an issue ("Fixes", or "Related to" for a partial fix).
  • This pull request uses the develop branch as its base.
  • This pull request subject follows the Conventional Commits standard.
  • This code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have provided a detailed enough description of this PR.

fn_dl_extract could report success when nothing was extracted:
- an unsupported MIME type matched no branch and the if returned 0
- in selective ZIP extraction the status came from rm, hiding unzip
  and cp failures

Fail explicitly on unsupported archive types, chain unzip and cp so
either failure is reported, clean up the temp directory only after
capturing the exit code, and capture stderr so the failure reason is
written to the log.
@github-actions github-actions Bot added the type: bugfix Pull request that fixes a bug label Oct 27, 2026
@dgibbs64 dgibbs64 added this to the v26.5.0 milestone Oct 29, 2026
@github-actions github-actions Bot added engine: factorio Issues related to factorio engine engine: idtech3 Issues related to idtech3 engine engine: renderware Issues related to renderware engine engine: null Issues related to null engine engine: unreal3 Issues related to unreal3 engine game: Factorio Issues related to Factorio game: Jedi Knight II: Jedi Outcast Issues related to Jedi Knight II: Jedi Outcast game: Multi Theft Auto Issues related to Multi Theft Auto game: Teamspeak 3 Issues related to Teamspeak 3 game: Xonotic Issues related to Xonotic labels Oct 29, 2026

@dgibbs64 dgibbs64 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this, and congratulations on your first LinuxGSM contribution! The write-up and the before/after test table made it a pleasure to review.

I ran it in the ubuntu-26.04 container and on a test server, against develop:

  • hlwonserver auto-install (tar.xz from linuxgsm.download), mtaserver auto-install (selective tar.gz) and xntserver auto-install (selective zip) all install exactly as before.
  • install-default-resources (full zip) extracts the same 2343 files.
  • With a read-only folder in the destination, develop printed the cp errors and then "Install Complete!" with exit code 0 for Xonotic. This branch stops with FAIL and exit code 1, with the errors in the script log.
  • A missing source folder in a selective zip, and an HTML error page saved as the archive, now fail cleanly instead of reporting OK with nothing extracted.

The exitbypass gap you described, plus a few related problems found while testing (update downloads not being forced, log directory failures exiting 0, and install-default-resources not exiting cleanly), are handled in #5113 so they could land alongside this.

Thanks again!

@dgibbs64
dgibbs64 merged commit aa5344b into GameServerManagers:develop Oct 30, 2026
17 checks passed
@dgibbs64 dgibbs64 linked an issue Nov 1, 2026 that may be closed by this pull request
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine: factorio Issues related to factorio engine engine: idtech3 Issues related to idtech3 engine engine: null Issues related to null engine engine: renderware Issues related to renderware engine engine: unreal3 Issues related to unreal3 engine game: Factorio Issues related to Factorio game: Jedi Knight II: Jedi Outcast Issues related to Jedi Knight II: Jedi Outcast game: Multi Theft Auto Issues related to Multi Theft Auto game: Teamspeak 3 Issues related to Teamspeak 3 game: Xonotic Issues related to Xonotic type: bugfix Pull request that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(core): propagate archive extraction and copy failures

2 participants