Repository navigation
[backport camel-4.22.x] CAMEL-25983: camel-github2 - getCommitFile reads the file of the commit - #28375
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 11 tested, 27 compile-only — current: 9 all testedMaveniverse Scalpel detected 38 affected modules (current approach: 9).
|
…odedContent on purpose Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
gnodet-bot
left a comment
There was a problem hiding this comment.
Solid rewrite that fixes a fundamentally broken producer — the old code was calling getBlob(commitSha) with the commit SHA instead of a blob SHA, which would fail at runtime. The new implementation using getFileContent(path, sha) is the correct GitHub API call.
Highlights:
readContent()correctly handles both content delivery modes: base64 for files ≤ 1 MB, blob API fallback for larger files — resource handling is clean (try-with-resources on the InputStream).- SHA validation (40 hex chars) gives clear errors instead of obscure GitHub API failures when users pass branch names or short SHAs.
- Test suite covers the key paths: path-via-header vs path-via-body, base64 vs blob content delivery, and the three validation error paths. Well-structured Mockito isolation against the GitHub API.
- Minor gaps:
InvalidPayloadExceptionpath (null body + no path header) and directory rejection are not tested, but those branches are correct by inspection — no hidden bugs there.
LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Claude Code on behalf of davsclaus
Backport of the camel-github2 part of #28373 (CAMEL-25983) to camel-4.22.x.
getCommitFile now reads the file of the commit. The commit comes from the
CamelGitHubCommitShaheader, which must be a commit id of 40 hexadecimal characters. The path comes from the newCamelGitHubFilePathheader, or else from the body. Previously the body was taken as the commit when the header was not set, and the operation could not give the content of a file. The upgrade note is in the 4.22 guide on main, in #28373.The one change from the main commit is the 3-argument
InvalidPayloadExceptionconstructor. The 12 camel-github2 unit tests pass.🤖 Generated with Claude Code