Skip to content

#2088: skip malformed PATH entries instead of failing with InvalidPathException#2089

Open
maybeec wants to merge 1 commit into
devonfw:mainfrom
maybeec:bugfix/systempath-invalid-path-robustness
Open

#2088: skip malformed PATH entries instead of failing with InvalidPathException#2089
maybeec wants to merge 1 commit into
devonfw:mainfrom
maybeec:bugfix/systempath-invalid-path-robustness

Conversation

@maybeec

@maybeec maybeec commented Jun 29, 2026

Copy link
Copy Markdown
Member

This PR fixes #2088

Implemented changes:

  • SystemPath now guards the per-segment Path.of(segment) call against InvalidPathException. A single malformed PATH entry (e.g. one containing an illegal character such as a newline on Windows or a NUL byte on any OS) is now skipped with a warning instead of throwing and aborting the whole SystemPath construction — which previously took down all of IDEasy during context setup.
  • Added a regression test SystemPathTest#testConstructorSkipsMalformedPathEntryAndKeepsValidOnes that builds a SystemPath from a PATH containing a malformed entry and asserts the valid entries are kept and a warning is logged.
  • Added the corresponding CHANGELOG.adoc entry.

Testing instructions

Please add conscise, understandable instructions on how a reviewer can test/verify the functionality of your contribution here:

  1. Run mvn -pl cli -am test -Dtest=SystemPathTest — all tests pass, including the new testConstructorSkipsMalformedPathEntryAndKeepsValidOnes.
  2. To confirm the test actually guards against the regression, temporarily revert the try/catch around Path.of(segment) in SystemPath (~line 99) back to Path path = Path.of(segment); and re-run step 1 — the new test fails with InvalidPathException. Restore the fix afterwards.
  3. (Optional, real-world) On Windows, set a PATH that contains a malformed entry (e.g. an embedded newline) and run any ide command: IDEasy now logs WARNING Ignoring invalid PATH entry '...' and continues instead of aborting.

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

…alidPathException

SystemPath called Path.of(segment) for every PATH entry without guarding
against InvalidPathException. A single malformed entry (e.g. one containing
an illegal character such as a newline on Windows or a NUL byte on any OS)
aborted the whole SystemPath construction and therefore all of IDEasy.

Invalid PATH entries are now skipped with a warning while all valid entries
continue to be processed.
@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Jun 29, 2026
@maybeec maybeec added java related to Java code, the Java Virtual Machine and directly related tooling (OpenJDK, Adoptium) windows specific for Microsoft Windows OS labels Jun 29, 2026
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 28396032515

Coverage increased (+0.01%) to 71.357%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 11 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

11 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/common/SystemPath.java 11 89.36%

Coverage Stats

Coverage Status
Relevant Lines: 16280
Covered Lines: 12116
Line Coverage: 74.42%
Relevant Branches: 7286
Covered Branches: 4700
Branch Coverage: 64.51%
Branches in Coverage %: Yes
Coverage Strength: 3.15 hits per line

💛 - Coveralls

@maybeec maybeec moved this from 🆕 New to Team Review in IDEasy board Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java related to Java code, the Java Virtual Machine and directly related tooling (OpenJDK, Adoptium) windows specific for Microsoft Windows OS

Projects

Status: Team Review

Development

Successfully merging this pull request may close these issues.

SystemPath throws InvalidPathException on a single malformed PATH entry, aborting all of IDEasy

2 participants