Skip to content

Stream archive listings to support large imports - #1300

Merged
Doezer merged 3 commits into
Doezer:mainfrom
JEFF7712:fix/stream-archive-listings
Nov 2, 2026
Merged

Doezer merged 3 commits into
Doezer:mainfrom
JEFF7712:fix/stream-archive-listings

Conversation

@JEFF7712

@JEFF7712 JEFF7712 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

A valid ZIP with 43,462 entries and 85.8 GiB of declared expanded data failed import because 7z l -slt produced more than the 10 MiB execFile stdout buffer. Both archive safety limits were satisfied, but the reported error contained the start of the listing instead of the actual subprocess failure.

Stream archive tool output and parse listing records incrementally. Integrity tests and extraction use the same runner, so verbose output cannot trigger the same buffer failure in a later import stage.

  • Preserve entry-count, expanded-size, unsafe-path, depth, link, and extraction staging checks, including split-volume RAR continuation handling.
  • Bound each listing record to 64 KiB and retained entry names to 32 MiB. Stop deterministically refused listings without retrying.
  • Classify listing password failures from stderr so filenames cannot trigger password prompts. Classify password failures before redacting diagnostic text, preserving the password prompt even for passwords such as password, pass, word, or a.
  • Keep bounded diagnostic tails with exit codes/signals, avoid password-bearing command-line errors, and reap failed or timed-out children with a forced-kill fallback.
  • Document the metadata memory limits in the security and operator documentation.

Validation

  • The generated 43,462-entry listing regression fails on unchanged bbc66b32 and passes with this change. It exceeds 10 MiB without requiring a large archive fixture.
  • Real subprocess tests cover chunked UTF-8/CRLF records, final unterminated records, multipart RAR continuations, oversized metadata, bounded diagnostics, subprocess failures, password redaction, and process cleanup.
  • Existing archive safety and extraction tests pass.
  • TZ=UTC npm test -- --maxWorkers=4: 4,746 passed, 7 skipped
  • npm run lint
  • npm run check
  • npm run build
  • Prettier checks for all changed files and pre-commit secretlint pass.

Type of change

  • Bug fix
  • Documentation update

Checklist

  • Followed project style and reviewed the diff
  • Added regression tests and updated existing tests
  • Updated relevant security and operator documentation
  • Backend-only change; no UI or database schema changes
  • Disclosed AI assistance below

AI assistance

Written with OpenAI Codex (GPT-6). The exact model variant and thinking level were not exposed by this session.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of large archive listings, including valid listings exceeding 10 MiB.
    • Archives with oversized listing records, excessive filename metadata, or too many entries are rejected promptly, without retrying extraction or creating an extraction destination.
    • Improved archive-process error reporting with bounded diagnostic output and password-value redaction.
    • Password-related failures are classified more reliably, while transient listing failures are less likely to be mistaken for password errors.
  • Documentation
    • Updated archive security guidance to describe metadata limits and safeguards.

@mintlify

mintlify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit b07156d.

Approve preview

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eb07c644-0f11-4889-ae90-430eefdc9ff5
Commits

Reviewing files that changed from the base of the PR and between b48ac18 and b07156d.

Files selected for processing: 3
  • server/__tests__/archive_service.test.ts
  • server/__tests__/archive_tool.test.ts
  • server/services/archive-tool.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

Archive subprocess output now streams through a shared runner. Archive listings are parsed record by record with limits on record size, entry count, and aggregate filename bytes. Failure diagnostics are bounded. Tests and security documentation cover the updated behavior.

Changes: Archive streaming

Layer / File(s) Summary
Archive process streaming
server/services/archive-tool.ts, server/__tests__/archive_tool.test.ts
Adds runArchiveTool to stream and parse process output, limit records, bound diagnostic tails, redact password arguments, and terminate failed or timed-out processes. Tests cover record boundaries, errors, and process cleanup.
Archive listing integration
server/services/ArchiveService.ts, server/__tests__/archive_service_streaming.test.ts, docs/SECRETS.md, docs/SECURITY_ASSESSMENT.md, docs/THREAT_MODEL.md
ArchiveService streams listing records, applies entry-count and aggregate name-byte limits, and treats listing-limit errors as non-retryable. Tests cover large listings, RAR continuation records, and rejection cases. Documentation describes the limits and bounded diagnostics.
Archive service process tests
server/__tests__/archive_service.test.ts
Updates process mocks to use spawn. Adds password-failure cases across ZIP and RAR listing and integrity operations.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ArchiveService
  participant runArchiveTool
  participant ArchiveProcess
  ArchiveService->>runArchiveTool: request streamed listing
  runArchiveTool->>ArchiveProcess: spawn archive command
  ArchiveProcess-->>runArchiveTool: stdout and stderr chunks
  runArchiveTool-->>ArchiveService: parsed listing records
Loading

Possibly related PRs

  • Doezer/Questarr#1172: Introduced archive-extraction limit documentation that this change updates for streamed listing and diagnostic limits.

Suggested labels: bug-fix, testing, import

Suggested reviewers: gitar-bot

Merge Risk: Minimal · up to b0715

No actionable merge-blocking risk was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Stream archive listings to support large imports" matches the main change in the changeset. The raw summary and objectives show that archive listing output is now parsed as a stream by runA…
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.
Full details: Title check

Explanation

The title "Stream archive listings to support large imports" matches the main change in the changeset. The raw summary and objectives show that archive listing output is now parsed as a stream by runArchiveTool and ArchiveService, which lifts the 10 MiB execFile buffer limit that caused large imports to fail. The title is short, specific, and uses no vague terms.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 5 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

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

@Doezer Doezer added archive-handling backend bug Something isn't working documentation Improvements or additions to documentation security labels Nov 2, 2026
@Doezer

Doezer commented Nov 2, 2026

Copy link
Copy Markdown
Owner

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

This PR fixes a bug where listing very large archives (e.g., ZIPs with tens of thousands of entries) could exceed the 10 MiB execFile stdout buffer, causing misleading errors during import. It refactors archive listing, integrity checking, and extraction to stream subprocess output incrementally with bounded record and entry-name size limits, while preserving existing safety checks (entry count, expanded size, unsafe paths, links, depth, RAR continuations), and adds bounded diagnostics, passwor…

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

Comment thread server/services/archive-tool.ts Resolved

@gitar-bot gitar-bot 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.

Gitar has auto-approved this PR (configure)

@coderabbitai coderabbitai 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.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread server/services/archive-tool.ts Resolved
@Doezer

Doezer commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thanks. I'll merge once the AI review approves

@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor
Code Review ✅ Approved 1 closed / 1 findings

🔴 High risk · Streaming archive metadata now feeds import safety checks; a parser regression could miss malicious paths or links and allow writes outside staging.

Streams archive tool output and parses listing records incrementally so large imports no longer hit the 10 MiB execFile buffer, with bounded record and metadata sizes and password classification from stderr before redaction. Password redaction that could mangle 'wrong password' classification was addressed. No open issues found.

✅ 1 closed
✅ Bug: Password redaction can mangle 'wrong password' and break classification

📄 server/services/archive-tool.ts:101-112 📄 server/services/ArchiveService.ts:334-344
In archive-tool.ts:103-107, every occurrence of the password text in the stderr/stdout tail gets replaced with [redacted]. If the password is a substring of the tool's own diagnostic, the diagnostic itself changes. Passwords like password, pass, word or a all do this: Wrong password? becomes Wrong [redacted]? or Wrong pass[redacted]?.

isPasswordProtectedError (ArchiveService.ts:78-82) then no longer matches wrong password|password is incorrect|.... The wrong-password failure is retried as if transient (about 11s of delay), and the user is told the archive is corrupt and should be re-downloaded. They never see the ArchivePasswordRequiredError that sends the download to the password prompt.

Fix: check for the password failure before redacting. One way is to return the raw-detail classification alongside the redacted message, for example const passwordFailure = isPasswordProtectedError(rawDetail), and throw a distinct error type. Another is to redact only when the password is long enough not to collide with tool text, while still classifying on the raw detail.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Approved

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@Doezer
Doezer merged commit df08e4d into Doezer:main Nov 2, 2026
8 checks passed
@Doezer Doezer added this to the 1.7.0 milestone Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

archive-handling backend bug Something isn't working documentation Improvements or additions to documentation security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants