#2088: skip malformed PATH entries instead of failing with InvalidPathException#2089
Open
maybeec wants to merge 6 commits into
Open
#2088: skip malformed PATH entries instead of failing with InvalidPathException#2089maybeec wants to merge 6 commits into
maybeec wants to merge 6 commits into
Conversation
…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.
Collaborator
Coverage Report for CI Build 28816040216Coverage increased (+0.04%) to 71.844%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions14 previously-covered lines in 1 file lost coverage.
Coverage Stats💛 - Coveralls |
…nvalid-path-robustness # Conflicts: # CHANGELOG.adoc
Following review feedback: besides ignoring broken entries via try/catch, PATH segments are now normalized by stripping illegal ISO control characters (CR, LF, NUL, TAB, etc.). This keeps otherwise usable entries (e.g. a valid path with a trailing newline from a broken tool config) instead of dropping them, while entries that only consist of control characters or remain invalid after normalization are still skipped without aborting SystemPath construction. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014bvJgB42fjjeN7qDboXQyg
Member
Author
|
@hohwille good point — done. PR #2089 now does both:
Added two regression tests covering both behaviours and updated the CHANGELOG entry accordingly. |
…le import
The changed-files checkstyle run flagged the pre-existing java.io.File import
(forbidden by the project ruleset). Its only use was File.pathSeparatorChar,
which the JDK derives from the "path.separator" system property, so replace it
with System.getProperty("path.separator").charAt(0) and drop the import.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014bvJgB42fjjeN7qDboXQyg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #2088
Implemented changes:
SystemPathnow normalizes eachPATHsegment by stripping illegal ISO control characters (CR, LF, NUL, TAB, etc.) before parsing it. An entry that is otherwise usable (e.g. a valid path with a trailing newline injected by a broken tool config) is thus cleaned and kept instead of being dropped.SystemPathadditionally guards the per-segmentPath.of(...)call againstInvalidPathExceptionas a safety net. A segment that consists only of control characters, or that is still malformed after normalization, is skipped with a warning instead of throwing and aborting the wholeSystemPathconstruction — which previously took down all of IDEasy during context setup.SystemPathTest:testConstructorNormalizesPathEntryWithControlCharactersAndKeepsIt— aPATHentry polluted with CR/LF/TAB/NUL is normalized and kept, and a warning is logged.testConstructorSkipsPathEntryConsistingOnlyOfControlCharactersAndKeepsValidOnes— aPATHentry made up entirely of control characters is skipped with a warning while the valid neighbours are kept.CHANGELOG.adocentry.Testing instructions
Please add conscise, understandable instructions on how a reviewer can test/verify the functionality of your contribution here:
mvn -pl cli -am test -Dtest=SystemPathTest— all tests pass, including the two new tests listed above.parsePathSegment(...)/normalizePathSegment(...)handling inSystemPathback to a plainPath path = Path.of(segment);and re-run step 1 — the new tests fail (InvalidPathException/ leftover control characters). Restore the fix afterwards.PATHthat contains a malformed entry (e.g. an embedded newline) and run anyidecommand: IDEasy now logsNormalized PATH entry '...'(orIgnoring 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.
mvn clean testlocally all tests pass and build is successful#«issue-id»: «brief summary»(e.g.#921: fixed setup.bat). If no issue ID exists, title only.In Progressand assigned to you or there is no issue (might happen for very small PRs)with
internal