Skip to content

Fix IllegalArgumentException in KotlinParser when dependsOn paths are relative#6882

Merged
jkschneider merged 2 commits intomainfrom
jkschneider/parser-charset
Mar 5, 2026
Merged

Fix IllegalArgumentException in KotlinParser when dependsOn paths are relative#6882
jkschneider merged 2 commits intomainfrom
jkschneider/parser-charset

Conversation

@jkschneider
Copy link
Copy Markdown
Member

Summary

  • dependsOn inputs created via determinePath have relative paths, but source inputs may have absolute paths
  • When relativeTo is absolute, Path.relativize throws IllegalArgumentException due to the absolute/relative mismatch
  • Resolves dependsOn paths against relativeTo before relativizing, preventing the crash

Test plan

  • Verify existing Kotlin parser tests pass
  • Test with Kotlin sources that have absolute paths and dependsOn with relative paths

…re relative

`dependsOn` inputs created via `determinePath` have relative paths, but source
inputs may have absolute paths. When `relativeTo` is absolute, resolve
dependsOn paths against it so `Path.relativize` in `getRelativePath` doesn't
throw `IllegalArgumentException` due to an absolute/relative mismatch.
…Path

The new test demonstrates the IllegalArgumentException that occurs when
dependsOn provides relative paths but relativeTo is absolute (e.g. a
@tempdir). Also adds the absolute/relative mismatch guard directly in
Parser.Input.getRelativePath, which is called from KotlinTreeParserVisitor.
@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Mar 5, 2026
@jkschneider jkschneider merged commit 2301028 into main Mar 5, 2026
1 check passed
@jkschneider jkschneider deleted the jkschneider/parser-charset branch March 5, 2026 16:08
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Mar 5, 2026
@asbachb
Copy link
Copy Markdown

asbachb commented Mar 9, 2026

Could you trigger a rebuild of gradle plugin with this fix included?

@timtebeek
Copy link
Copy Markdown
Member

Hi @asbachb ; the fix should already be available through our snapshot versions; we'll resume our regular release schedule next week. Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants