Skip to content

fix: reject relative complete_dir/incomplete_dir in SABnzbd import - #67

Merged
thedancingdeveloper merged 1 commit into
mainfrom
fix/sabnzbd-import-relative-paths
Aug 10, 2026
Merged

fix: reject relative complete_dir/incomplete_dir in SABnzbd import#67
thedancingdeveloper merged 1 commit into
mainfrom
fix/sabnzbd-import-relative-paths

Conversation

@thedancingdeveloper

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #62/#63. The reporter confirmed the diagnostics fix worked and found the actual root cause: importing their SABnzbd config set complete_dir/incomplete_dir to a relative path ("Downloads") that didn't match their Docker volume mount (/downloads), reproducing the crash — see #62 (comment) and the follow-up root-cause writeup at #62 (comment).

crates/nzb-core/src/sabnzbd_import.rs read SABnzbd's complete_dir/download_dir as raw strings with no path validation, and apps/rustnzb/src/handlers.rs (h_setup_apply) wrote them straight into config via a bare PathBuf::from(dir) — no is_absolute() check. A relative path gets silently persisted, then create_dir_all at startup resolves it against the process's CWD instead of the intended volume.

Fix

  • h_setup_apply: reject (400 Bad Request) any non-absolute complete_dir/incomplete_dir before touching config — the actual safety net, so a broken import can never be persisted regardless of what the frontend does.
  • Both import parsers (INI + live SABnzbd API): add a warning to the preview's existing warnings: Vec<String> list when either dir is relative, via a shared warn_relative_dirs helper — surfaces the problem on the review-before-apply screen, same UX pattern already used for masked passwords / unsupported scripts.

Test plan

  • cargo test -p nzb-core --lib sabnzbd_import: new unit tests — relative dir → warning (INI + API parser), absolute dir → no warning (INI parser)
  • cargo test -p rustnzb --test sabnzbd_import_apply_test: new integration tests calling h_setup_apply directly — relative complete_dir rejected + config left untouched, relative incomplete_dir rejected + config left untouched, absolute dirs applied successfully
  • Full existing suites green: cargo test -p nzb-core --lib (118 passed), cargo test -p rustnzb --tests (all e2e/integration/unit)
  • cargo fmt --check / cargo clippy --all-targets -- -D warnings clean

Closes #62.

🤖 Generated with Claude Code

SABnzbd allows relative complete_dir/download_dir paths (resolved
against its own working directory), but the import silently copied
them verbatim into config.toml. rustnzb creates these directories
eagerly at startup via create_dir_all, which resolves a relative path
against the process's CWD instead of the intended download volume —
producing a confusing crash far from the actual misconfiguration.
Reported (and root-caused) by the #62 reporter after a SABnzbd import
set their dirs to "Downloads" against a Docker volume at "/downloads".

- h_setup_apply now rejects (400) non-absolute complete_dir/
  incomplete_dir before touching config, so a broken import can never
  be persisted.
- Both import parsers (INI + live API) now add a warning to the
  preview when either dir is relative, so the frontend's
  review-before-apply screen can flag it before the user even tries
  to apply.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@thedancingdeveloper
thedancingdeveloper merged commit 7614ec3 into main Aug 10, 2026
6 checks passed
@thedancingdeveloper
thedancingdeveloper deleted the fix/sabnzbd-import-relative-paths branch August 10, 2026 22:10
thedancingdeveloper added a commit that referenced this pull request Aug 10, 2026
Ships the SABnzbd import path-validation fix (#67): relative
complete_dir/incomplete_dir are now rejected at apply time instead of
being silently persisted and crashing on next startup.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Permission denied" in Synology container manager

1 participant