langchain4j/document-loaders/langchain4j-document-loader.../src
Eunbin Son 0626661baa
fix: Include failing file URL in GitHubDocumentLoader load-failure exception message (#5684)
## Issue
Closes #5683

## Change

`GitHubDocumentLoader.fromGitHub()` wrapped an `IOException` using an
SLF4J `{}` placeholder. `RuntimeException(String, Throwable)` never
substitutes `{}`, so the message leaked a literal `{}` and dropped the
failing file's URL. The fix concatenates `content.getHtmlUrl()`,
matching the sibling message on line 210:

```java
throw new RuntimeException("Failed to load document from GitHub: " + content.getHtmlUrl(), ioException);
```

Control flow, return value, and exception type are unchanged; backward
compatible.

Added `GitHubDocumentLoaderTest` (the module's first unit test): it
injects a mock `GitHub` via the `GitHubDocumentLoader(GitHub)`
constructor, forces `GHContent.read()` to throw, and asserts the message
contains the URL and not `{}` (positive and negative).

## General checklist
- [X] There are no breaking changes (API, behaviour)
- [X] I have added unit and/or integration tests for my change
- [X] The tests cover both positive and negative cases
- [X] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the core
and main modules, and they are all green <!-- N/A: change isolated to
github document-loader module -->
- [ ] I have added/updated the documentation <!-- N/A: no public
API/behavior contract change -->
- [ ] I have added an example in the examples repo <!-- N/A: bug fix,
not a feature -->
- [ ] I have added/updated Spring Boot starter(s) <!-- N/A: not
applicable -->

## Build / test evidence
- `./mvnw -pl document-loaders/langchain4j-document-loader-github -am
clean test` (JDK 17): GitHubDocumentLoaderTest 1 run, 0 failures. IT
skipped (`@EnabledIfEnvironmentVariable` GITHUB_TOKEN absent).
- Spotless verified via MAIN_ROOT `spotless:apply` (jgit `ratchetFrom`
cannot open a git worktree's file-based `.git`): no reformatting of
either file.
2026-07-06 10:27:18 +02:00
..
main/java/dev/langchain4j/data/document fix: Include failing file URL in GitHubDocumentLoader load-failure exception message (#5684) 2026-07-06 10:27:18 +02:00
test fix: Include failing file URL in GitHubDocumentLoader load-failure exception message (#5684) 2026-07-06 10:27:18 +02:00