Skip to content

Fix 7zip bin permissions in docker file #802 - #803

Open
Doezer wants to merge 11 commits into
mainfrom
fix-7zip-permission-issue
Open

Fix 7zip bin permissions in docker file #802#803
Doezer wants to merge 11 commits into
mainfrom
fix-7zip-permission-issue

Conversation

@Doezer

@Doezer Doezer commented Jul 18, 2026

Copy link
Copy Markdown
Owner

This pull request updates the Dockerfile to address a runtime permissions issue with the 7zip-bin package. Specifically, it ensures that the 7za binary is executable, which prevents extraction failures due to permission errors.

Build and runtime reliability:

  • Added a RUN find command to explicitly set the executable bit on all 7z* files within node_modules/7zip-bin, ensuring the 7za binary is runnable and preventing EACCES errors at runtime.

Summary by CodeRabbit

  • Bug Fixes
    • Improved production builds for archive tooling by adding libarchive-tools and ensuring bundled 7-Zip executables have correct permissions to prevent runtime access errors.
    • Enhanced archive extraction reliability: RAR now uses the dedicated backend with pre-validation; output folders aren’t created when validation fails; extraction warns when no files are produced or when required tooling is unavailable.
  • Maintenance
    • Improved import cleanup so temporary extraction/processing directories are removed consistently across error and manual-review flows.
  • Tests
    • Added/expanded automated coverage for RAR handling and import/extraction failure scenarios.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Archive extraction now validates archives, routes RAR files through bsdtar, restores 7zip executable permissions in production, and cleans temporary import paths across extraction failures and manual-review flows. Tests cover the new extraction and cleanup behavior.

Changes

Archive extraction and import cleanup

Layer / File(s) Summary
Archive backend routing and validation
server/services/ArchiveService.ts
Archive extraction validates inputs, selects bsdtar for RAR files and 7zip for other supported formats, lists extracted files, and logs empty results.
Import extraction cleanup
server/services/ImportManager.ts
Import flows remove temporary extraction directories after failures, manual-review processing, and unpacked confirmation, while suppressing cleanup errors.
Runtime packaging and validation
Dockerfile, server/__tests__/archive_service.test.ts, server/__tests__/import_manager.test.ts
The production image installs libarchive-tools and restores 7zip executable permissions; tests cover RAR routing, warnings, failures, status updates, and temporary-path cleanup.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ImportManager
  participant ArchiveService
  participant bsdtar
  participant 7za
  ImportManager->>ArchiveService: extract archive
  ArchiveService->>bsdtar: test and extract RAR
  ArchiveService->>7za: test and extract non-RAR archive
  ArchiveService-->>ImportManager: return extracted file paths
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the primary Dockerfile change to fix 7zip binary permissions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-7zip-permission-issue

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Dockerfile to explicitly set the executable permission on 7zip-bin binaries to prevent runtime EACCES errors. The feedback suggests combining this new RUN command with the preceding npm prune command into a single instruction to minimize the number of layers in the final Docker image.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread Dockerfile Outdated
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.93814% with 2 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
server/services/ArchiveService.ts 98.76% 1 Missing ⚠️
server/services/ImportManager.ts 93.75% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Doezer

Doezer commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

Wait for confirmation of user

@Doezer Doezer linked an issue Jul 18, 2026 that may be closed by this pull request
Doezer added 3 commits July 26, 2026 15:46
The bundled 7za binary cannot decode RAR archives, so .rar downloads
silently produced an empty *_extracted folder instead of failing loudly.
Route .rar through the system unrar binary (apk add unrar), validate
archives before creating any output directory, and clean up on failure
in ImportManager's extractIfArchive/confirmImport/processImport paths.
@Doezer
Doezer force-pushed the fix-7zip-permission-issue branch from 03ea91c to aac264e Compare July 26, 2026 22:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Dockerfile`:
- Around line 38-42: Remove all trailing whitespace after the line-continuation
backslashes in the Dockerfile RUN instruction, especially the continuation
following “npm prune --omit=dev”, so the chained find/chmod command remains part
of the same Docker instruction.
- Around line 28-32: Update the Dockerfile dependency installation so the unrar
extractor is obtained through a supported non-apk installation path or replaced
with a supported extraction dependency; remove reliance on apk add unrar while
preserving installation of su-exec, shadow, Python, and Apprise.

In `@server/services/ArchiveService.ts`:
- Around line 53-83: Update the unrar argument construction in the relevant
archive test/extraction flows to insert `--` before the test operand and before
both archive and output-directory operands, preventing downloaded paths
beginning with `-` from being parsed as switches. Then update the corresponding
`execFile` argument assertions in the archive service tests to expect the new
separators.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fa02af37-cb6e-4354-9b9a-6b206de80461

📥 Commits

Reviewing files that changed from the base of the PR and between 03ea91c and aac264e.

📒 Files selected for processing (5)
  • Dockerfile
  • server/__tests__/archive_service.test.ts
  • server/__tests__/import_manager.test.ts
  • server/services/ArchiveService.ts
  • server/services/ImportManager.ts

Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread server/services/ArchiveService.ts Outdated
Alpine 3.24 (node:26-alpine) no longer ships a standalone unrar
package in main or community, so `apk add unrar` fails CI's
docker-build check. Alpine's libarchive-tools package (bsdtar) is
statically linked with archive_read_support_format_rar and _rar5,
covering both legacy and RAR5 archives including multi-volume sets,
without depending on RARLAB's non-free unrar binary.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/services/ArchiveService.ts (1)

18-49: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting shared fixed-path binary resolution logic.

The comment notes this "Mirrors server/apprise.ts's resolveAppriseBinary" — the candidate-list + env-override + accessSync caching pattern is duplicated verbatim in spirit between the two files. A small shared helper (e.g. resolveFixedBinary(candidates, envVar)) would remove this duplication for future additions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/services/ArchiveService.ts` around lines 18 - 49, Extract the
duplicated fixed-path binary lookup logic from resolveBsdtarBinary and the
corresponding resolveAppriseBinary implementation into a shared helper, such as
resolveFixedBinary, accepting candidate paths and the environment-variable name.
Preserve environment override ordering, executable checks via accessSync, and
cached resolution behavior for both callers, then update each resolver to use
the shared helper.
♻️ Duplicate comments (1)
Dockerfile (1)

39-43: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Trailing whitespace after the \ line-continuation breaks this RUN instruction.

Line 42 ends with && \ followed by trailing spaces. Since the backslash is no longer the last character on the line, Docker will not join Line 43 into this RUN; the shell receives a dangling && with no following command (syntax error), and the standalone find ... line becomes an unrecognized Dockerfile instruction. This breaks the build and defeats the PR's goal of making 7z* executable. This is the same defect flagged (and left unaddressed) in a prior review round on this file.

🐛 Proposed fix — strip trailing whitespace after `\`
-RUN npm prune --omit=dev && \  
-    find node_modules/7zip-bin -type f -name "7z*" -exec chmod +x {} +  
+RUN npm prune --omit=dev && \
+    find node_modules/7zip-bin -type f -name "7z*" -exec chmod +x {} +
#!/bin/bash
# Confirm trailing whitespace after line-continuation backslashes
grep -nP '\\[ \t]+$' Dockerfile || echo "no trailing-whitespace-after-backslash found"
sed -n '38,43p' Dockerfile | cat -A
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` around lines 39 - 43, Remove all trailing spaces after the
line-continuation backslash in the RUN instruction containing npm prune and
find. Ensure the backslash is the final character on the continuation line so
the find command remains part of the same Dockerfile RUN instruction.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@server/services/ArchiveService.ts`:
- Around line 18-49: Extract the duplicated fixed-path binary lookup logic from
resolveBsdtarBinary and the corresponding resolveAppriseBinary implementation
into a shared helper, such as resolveFixedBinary, accepting candidate paths and
the environment-variable name. Preserve environment override ordering,
executable checks via accessSync, and cached resolution behavior for both
callers, then update each resolver to use the shared helper.

---

Duplicate comments:
In `@Dockerfile`:
- Around line 39-43: Remove all trailing spaces after the line-continuation
backslash in the RUN instruction containing npm prune and find. Ensure the
backslash is the final character on the continuation line so the find command
remains part of the same Dockerfile RUN instruction.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e737564a-05c4-43c8-8e74-c8138fe21b45

📥 Commits

Reviewing files that changed from the base of the PR and between aac264e and 620664f.

📒 Files selected for processing (3)
  • Dockerfile
  • server/__tests__/archive_service.test.ts
  • server/services/ArchiveService.ts

Remove trailing whitespace after Dockerfile RUN line continuation
(was breaking the chmod chain from npm prune), sort apk package
names alphanumerically, and prefer node: prefixed built-in imports
in ArchiveService and its tests.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
server/__tests__/archive_service.test.ts (1)

293-293: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Restore BSDTAR_PATH after each test.

This test file deletes BSDTAR_PATH in beforeEach but assigns it in the RAR tests, so a final assignment can persist for later tests in the same worker. Add afterEach(() => delete process.env.BSDTAR_PATH) here or restore it after assignment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/__tests__/archive_service.test.ts` at line 293, Ensure the RAR tests
clean up the BSDTAR_PATH environment variable after each test by adding an
afterEach cleanup or restoring its prior value after the assignment near
fakeBsdtarPath. Preserve the existing test setup while preventing BSDTAR_PATH
from leaking into later tests.
server/services/ArchiveService.ts (1)

113-120: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Return only regular files.

listExtractedFiles() only skips directories, so extractWithBsdtar() can return symlink and special-entry paths from the target directory. Use entry.isFile() to filter out non-regular entries before returning paths.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/services/ArchiveService.ts` around lines 113 - 120, Update the
directory traversal in listExtractedFiles() to add paths only when
entry.isFile() is true, while continuing to recurse into directories via walk().
Exclude symlinks and other special entries from results returned to
extractWithBsdtar().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Dockerfile`:
- Around line 32-33: Pin every dependency introduced by the Dockerfile RUN
command, including libarchive-tools, py3-pip, python3, shadow, su-exec, and
apprise. Use explicit apk package versions and a pinned apprise version or
constraints file so repeated builds resolve identical image-layer dependencies.

In `@server/services/ArchiveService.ts`:
- Around line 1-7: Reorder the imports in ArchiveService so the built-in
node:path import is grouped with the other node: imports at the top, before
third-party modules such as node-7z and 7zip-bin; leave the imported symbols and
behavior unchanged.

---

Outside diff comments:
In `@server/__tests__/archive_service.test.ts`:
- Line 293: Ensure the RAR tests clean up the BSDTAR_PATH environment variable
after each test by adding an afterEach cleanup or restoring its prior value
after the assignment near fakeBsdtarPath. Preserve the existing test setup while
preventing BSDTAR_PATH from leaking into later tests.

In `@server/services/ArchiveService.ts`:
- Around line 113-120: Update the directory traversal in listExtractedFiles() to
add paths only when entry.isFile() is true, while continuing to recurse into
directories via walk(). Exclude symlinks and other special entries from results
returned to extractWithBsdtar().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 42740df9-822a-483b-8384-8e2479393d1e

📥 Commits

Reviewing files that changed from the base of the PR and between 620664f and 6c17bc5.

📒 Files selected for processing (3)
  • Dockerfile
  • server/__tests__/archive_service.test.ts
  • server/services/ArchiveService.ts

Comment thread Dockerfile Outdated
Comment thread server/services/ArchiveService.ts Outdated
Pin apprise to 1.9.4 via pip (PyPI retains all versions, so this is
safe long-term). Left the apk packages unpinned since Alpine's apk
repos only keep the current build of each package per release branch
- pinning to an exact NVR would make the build fail as soon as any of
those packages gets a routine security bump.
@Doezer

Doezer commented Jul 27, 2026

Copy link
Copy Markdown
Owner Author

/deploy tag=bsdtar

Deployment Summary

  • Environment: test
  • Image: ghcr.io/doezer/questarr
  • Docker Hub: doezer/questarr
  • Tags: ghcr.io/doezer/questarr:bsdtar
    ghcr.io/doezer/questarr:test-sha-e0491b6
    doezer/questarr:bsdtar
    doezer/questarr:test-sha-e0491b6
  • SBOM: attached to the image as an attestation, and uploaded as the sbom-questarr-1.4.1-test workflow artifact

Pull and run the image:

docker pull ghcr.io/doezer/questarr:$TAG
docker run -d -p 5000:5000 \
  -e POSTGRES_PASSWORD=your_password \
  -e IGDB_CLIENT_ID=your_client_id \
  -e IGDB_CLIENT_SECRET=your_client_secret \
  ghcr.io/doezer/questarr:$TAG

Inspect the SBOM attestation:

docker buildx imagetools inspect ghcr.io/doezer/questarr:$TAG --format '{{ json (index .SBOM "linux/amd64").SPDX }}'

@Doezer Doezer added this to the 1.4.1 milestone Jul 28, 2026
@Doezer

Doezer commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

/deploy tag=bsdtar

Deployment Summary

  • Environment: test
  • Image: ghcr.io/doezer/questarr
  • Docker Hub: doezer/questarr
  • Tags: ghcr.io/doezer/questarr:bsdtar
    ghcr.io/doezer/questarr:test-sha-e0491b6
    doezer/questarr:bsdtar
    doezer/questarr:test-sha-e0491b6
  • SBOM: attached to the image as an attestation, and uploaded as the sbom-questarr-1.4.1-test workflow artifact

Pull and run the image:

docker pull ghcr.io/doezer/questarr:$TAG
docker run -d -p 5000:5000 \
  -e POSTGRES_PASSWORD=your_password \
  -e IGDB_CLIENT_ID=your_client_id \
  -e IGDB_CLIENT_SECRET=your_client_secret \
  ghcr.io/doezer/questarr:$TAG

Inspect the SBOM attestation:

docker buildx imagetools inspect ghcr.io/doezer/questarr:$TAG --format '{{ json (index .SBOM "linux/amd64").SPDX }}'

@Doezer

Doezer commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

/deploy tag=bsdtar

Deployment Summary

  • Environment: test
  • Image: ghcr.io/doezer/questarr
  • Docker Hub: doezer/questarr
  • Tags: ghcr.io/doezer/questarr:bsdtar
    ghcr.io/doezer/questarr:test-sha-070d284
    doezer/questarr:bsdtar
    doezer/questarr:test-sha-070d284
  • SBOM: attached to the image as an attestation, and uploaded as the sbom-questarr-1.4.1-test workflow artifact

Pull and run the image:

docker pull ghcr.io/doezer/questarr:$TAG
docker run -d -p 5000:5000 \
  -e POSTGRES_PASSWORD=your_password \
  -e IGDB_CLIENT_ID=your_client_id \
  -e IGDB_CLIENT_SECRET=your_client_secret \
  ghcr.io/doezer/questarr:$TAG

Inspect the SBOM attestation:

docker buildx imagetools inspect ghcr.io/doezer/questarr:$TAG --format '{{ json (index .SBOM "linux/amd64").SPDX }}'

Doezer and others added 3 commits August 13, 2026 14:06
The confirmImport catch handler routes failures to
manual_review_required (added in #840) so failed imports stay
actionable and retryable, instead of a terminal 'error' status.
The extraction-failure test added by this PR still asserted the old
'error' status, causing CI to fail.
Fix stale test assertion causing CI failure on #803
@sonarqubecloud

Copy link
Copy Markdown

@Doezer

Doezer commented Aug 13, 2026

Copy link
Copy Markdown
Owner Author

/deploy tag=bsdtar

Deployment Summary

  • Environment: test
  • Image: ghcr.io/doezer/questarr
  • Docker Hub: doezer/questarr
  • Tags: ghcr.io/doezer/questarr:bsdtar
    ghcr.io/doezer/questarr:test-sha-260dd04
    doezer/questarr:bsdtar
    doezer/questarr:test-sha-260dd04
  • SBOM: attached to the image as an attestation, and uploaded as the sbom-questarr-1.4.3-test workflow artifact

Pull and run the image:

docker pull ghcr.io/doezer/questarr:$TAG
docker run -d -p 5000:5000 \
  -e POSTGRES_PASSWORD=your_password \
  -e IGDB_CLIENT_ID=your_client_id \
  -e IGDB_CLIENT_SECRET=your_client_secret \
  ghcr.io/doezer/questarr:$TAG

Inspect the SBOM attestation:

docker buildx imagetools inspect ghcr.io/doezer/questarr:$TAG --format '{{ json (index .SBOM "linux/amd64").SPDX }}'

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.

[Support] Import failed when unpacking .rar file

2 participants