Repository navigation
fix(kotlin): match pathMatcher against paths relative to the traversed directory - #6378
Open
Lubaoshuai wants to merge 1 commit into
Open
Lubaoshuai wants to merge 1 commit into
Lubaoshuai wants to merge 1 commit into
Conversation
…d directory loadDocuments matched the paths emitted by Files.walk (absolute for the configured directories) directly against the pathMatcher, so relative globs such as 'glob:*.txt' never matched and the call silently returned an empty list. FileSystemDocumentLoader documents the opposite contract: paths are relativized against the directory before matching. Relativize each walked path against the traversed directory before matching and add a regression test with a relative glob. Fixes langchain4j#6074
This branch has not been deployed
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.
Issue
Fixes #6074
Change
The Kotlin
loadDocumentsextension matched the paths emitted byFiles.walkdirectly against thepathMatcher. Those paths are absolute (rooted at the configured directory), so relative globs such asglob:*.txtnever matched anything and the call silently returned an empty list.This diverges from
FileSystemDocumentLoader, which documents (on three public overloads) that each file path is converted from absolute to relative — relative todirectoryPath— before being matched, and which relativizes inloadDocuments(Stream, PathMatcher, Path, DocumentParser).The Kotlin extension now calls
path.relativize(file)before matching (paths are still passed toFileSystemSourcein absolute form, so loading is unchanged).Test
Added
Should loadDocuments with a relative pathMatchertoAsyncDocumentLoaderTest: recursive load of the existingasyncDocumentLoaderTestresources withglob:*.txtnow returns exactly the top-levelfile1.txt(previously: empty list).mvn -pl langchain4j-kotlin -am test: all module tests pass.