Skip to content

fix: a downloaded archive whose root entry is ./ gives its language server a command without /./ - #2192

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/download-root-entry-dot
Nov 24, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/download-root-entry-dot

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2139

What

An archive whose root entry is ./, as the .tar.gz assets of cpp_ls are (./ and ./cpp_ls), gave its language
server a command with /./: "$USER_HOME$/.lsp4ij/lsp/cpp_ls/./cpp_ls", with ${output.dir}=…/cpp_ls/.. The server
started, but the path showed in the settings and in the LSP console, and replaceTemplateCommand compares a command as
written.

While testing it, two failures of the same cause showed up:

  • with stripRootFolder, the installation failed with "Invalid argument", moving the folder . into itself;
  • an archive of one folder under ./, such as ./server-1.0/bin/server, failed to find its output.file.name in
    <dir>/..

Cause

DownloadUtils.decompress took the first path segment of each entry as the archive's top level. For ./ and
./cpp_ls, that made . the single root folder, which DownloadTask then appended to the output dir, or tried to
strip.

Change

In DownloadUtils.decompress, the top level of an entry is its first segment that isn't . or empty. The entry ./
has none.

  • cpp_ls: its single root is the file cpp_ls, which isn't a folder, so nothing is appended.
  • An archive of one folder under ./: that folder is appended, as for one without ./.

Normalizing in DownloadTask instead, as the issue suggested, wouldn't work: <dir>/. normalized is <dir>, whose name
cpp_ls would then be appended, giving …/cpp_ls/cpp_ls/cpp_ls.

  • .. can't reach this code: IntelliJ's Decompressor rejects entries with ...
  • A leading / is already stripped by Decompressor.Entry.

I checked the real assets with gh release download. cpp_ls-darwin-arm64.tar.gz has exactly ./ and ./cpp_ls.
cpp_ls-win32-x64.zip has only cpp_ls.exe, and was never affected.

Tests

New DownloadTaskArchiveRootTest (8 tests). It runs the bundled cpp_ls installer.json, with its download replaced by
a file: URL to an archive built in a temp folder: a .tar.gz written with commons-compress, or a .zip. Each test
checks ${output.dir}, the exact command, and where the server file ends up.

  • ./ root: .tar.gz and .zip, each with and without stripRootFolder;
  • a plain single-root folder (cpp_ls-1.0/…), which still appends its name;
  • one folder under ./, .tar.gz and .zip, which appends cpp_ls-1.0;
  • stripRootFolder with one folder under ./, which strips it.

Without the fix, 7 of the 8 fail; only the plain single-root folder passes. With it, all pass, also headless. The
installation.* tests pass on IC 2024.2, 2025.3 and IU 2026.3: 194 each, with 0 failures or skipped.

Behaviour change

Before After
An archive whose root entry is ./ (cpp_ls on macOS and Linux) gives the command "$USER_HOME$/.lsp4ij/lsp/cpp_ls/./cpp_ls". With stripRootFolder, the installation fails with "Invalid argument". An archive of one folder under ./ fails to find its output.file.name The command is "$USER_HOME$/.lsp4ij/lsp/cpp_ls/cpp_ls". stripRootFolder works, and an archive of one folder under ./ appends that folder's name, as one without ./ does

…erver a command without /./

The extraction took the first segment of each entry as the top level of the
archive, so an archive whose root entry is ./, as the .tar.gz of cpp_ls, had
the single root folder ".". The download then appended it to ${output.dir},
which gave cpp_ls the command "$USER_HOME$/.lsp4ij/lsp/cpp_ls/./cpp_ls".

The top level of an entry is now its first segment that isn't "." or empty,
and the entry ./ has none. So for such an archive:
- ${output.dir} and the command have no /./: cpp_ls gets
  "$USER_HOME$/.lsp4ij/lsp/cpp_ls/cpp_ls".
- With stripRootFolder, the install no longer fails with "Invalid argument"
  while moving the folder "." into itself.
- An archive of one folder under ./, as ./server-1.0/bin/server, adds the
  name of that folder, as one without ./ does, instead of failing to find its
  output.file.name in "<dir>/.".

Fixes redhat-developer#2139
@lagergren lagergren added this to the 0.30.2 milestone Nov 24, 2026
@lagergren lagergren added the bug Something isn't working label Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved archive installation for TAR.GZ and ZIP files, including archives whose contents use ./ paths. Installed server commands no longer include invalid /./ path segments.
  • Tests
    • Added coverage for archive installation with and without a root folder, including cases where the root folder is stripped.

Archive root detection now skips empty and dot path components after normalizing separators. Installer tests cover TAR.GZ and ZIP archives with dot roots and single-folder roots, with and without stripRootFolder.

Changes: Archive root handling

Layer / File(s) Summary
Root detection and installation validation
src/main/java/com/redhat/devtools/lsp4ij/installation/download/DownloadUtils.java, src/test/java/com/redhat/devtools/lsp4ij/installation/definition/tasks/DownloadTaskArchiveRootTest.java
DownloadUtils normalizes archive entry separators and skips empty and . components when detecting the root. Tests verify installation paths, server commands, and installed contents for TAR.GZ and ZIP archive cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to fce4d

Archive extraction now ignores a leading "./" when deciding the top-level folder, so the cpp_ls command no longer contains "/./". The change is small and covered by new installer tests, so merge-readiness risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the specific fix: a downloaded archive whose root entry is ./ no longer gives the language server a command containing /./. The changeset normalizes the archive top-level detection in …
Description check Passed The description states the linked issue (#2139), the cause (first path segment treated as archive root, so '.' became the root folder), the change in DownloadUtils.decompress, the new tests, and the b…
Linked Issues check Passed Directly linked issue #2139 requires that a root entry of . add nothing to ${output.dir}, so the cpp_ls command has no /./. At the reviewed head, DownloadUtils.decompress takes the first path …
Out of Scope Changes check Passed The PR summary lists changes to two files only: DownloadUtils.java (+7/-5, the decompress top-level derivation and its comment) and the new test DownloadTaskArchiveRootTest.java. Both connect to…
Full details: Title check

Explanation

The title names the specific fix: a downloaded archive whose root entry is ./ no longer gives the language server a command containing /./. The changeset normalizes the archive top-level detection in DownloadUtils.decompress (ignoring '.' and empty segments) and adds DownloadTaskArchiveRootTest, which matches this change.

Full details: Description check

Explanation

The description states the linked issue (#2139), the cause (first path segment treated as archive root, so '.' became the root folder), the change in DownloadUtils.decompress, the new tests, and the before/after behaviour. This matches the raw summary and objectives.

Full details: Linked Issues check

Explanation

Directly linked issue #2139 requires that a root entry of . add nothing to ${output.dir}, so the cpp_ls command has no /./. At the reviewed head, DownloadUtils.decompress takes the first path segment that is neither empty nor . as the archive top level. For the entry ./, no segment remains, so it adds no top-level folder. For ./cpp_ls, the top level is cpp_ls. In cpp_ls, that top level is a file, so DownloadTask (which appends the folder name only when Files.isDirectory(decompressedDir) holds) appends nothing. The command becomes $USER_HOME$/.lsp4ij/lsp/cpp_ls/cpp_ls, as the issue expects. The change also covers stripRootFolder with a . root, which no longer tries to move . into itself. The new DownloadTaskArchiveRootTest (8 tests, per the PR description) covers .tar.gz and .zip cases. I did not read the test file. The test results are author-reported, not verified here. The issue is a coding requirement, and the code change meets it. Unresolved: the whole-PR diff could not be read (changed blobs unavailable), so the base-to-head change set is taken from the PR summary and the head file contents.

Full details: Out of Scope Changes check

Explanation

The PR summary lists changes to two files only: DownloadUtils.java (+7/-5, the decompress top-level derivation and its comment) and the new test DownloadTaskArchiveRootTest.java. Both connect to #2139: the decompress change fixes the root-folder derivation, and the test checks the resulting command and output path. The head DownloadUtils.java also contains decompressGz with REPLACE_EXISTING, and DownloadTask contains moveContentInto. The PR summary does not list these as changed, and they are not part of the described fix. The whole-PR diff could not be read to confirm they predate this PR, so this verdict relies on the summary's file list. They do not appear to be unrelated changes.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 68c24212-fd5b-4f97-b7db-67630ef8700d
Commits

Reviewing files that changed from the base of the PR and between 084bf75 and fce4d87.

Files selected for processing: 2

  • src/main/java/com/redhat/devtools/lsp4ij/installation/download/DownloadUtils.java
  • src/test/java/com/redhat/devtools/lsp4ij/installation/definition/tasks/DownloadTaskArchiveRootTest.java

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

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 54.25%. Comparing base (084bf75) to head (fce4d87).

Files with missing lines Patch % Lines
...ls/lsp4ij/installation/download/DownloadUtils.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2192      +/-   ##
==========================================
+ Coverage   54.23%   54.25%   +0.01%     
==========================================
  Files         832      832              
  Lines       35334    35334              
  Branches     7286     7286              
==========================================
+ Hits        19163    19169       +6     
+ Misses      13348    13342       -6     
  Partials     2823     2823              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit 84b4ec3 into redhat-developer:main Nov 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A downloaded archive whose root entry is ./ gives its language server a command with /./

1 participant