Repository navigation
[backport camel-4.18.x] CAMEL-25983: camel-github2 - getCommitFile reads the file of the commit - #28374
Conversation
gnodet-bot
left a comment
There was a problem hiding this comment.
LGTM. Clean rewrite that fixes the fundamentally broken original: the old code passed the commit SHA to getBlob() (which expects a blob SHA), and had dead-code branches doing the same thing in both arms of an if-else. The new implementation correctly uses getFileContent(path, sha) with proper SHA format validation, path traversal protection, and a correct blob fallback for files over 1 MB.
Two minor low-severity observations that don't block merge:
This review was generated by an AI agent, Hermès on behalf of @gnodet.
…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.
Non-blocking — the approach is sound.
readContent() correctly uses getEncodedContent() for base64 content and falls back to the blob API for large files (encoding != "base64"), which avoids the GHContent.read() breakage reported in hub4j/github-api#1558. The @SuppressWarnings("deprecation") is justified because there is no non-deprecated alternative that handles both cases.
One minor suggestion: add a short inline comment (or a link to the hub4j issue) next to the @SuppressWarnings annotation so the reason is clear to future readers without having to hunt for the issue reference. Something like:
// GHContent.read() is broken for files >1MB (hub4j/github-api#1558); getEncodedContent() is the only reliable path for base64 content.
@SuppressWarnings("deprecation")
Everything else — the path traversal guard, the blob fallback, and the test coverage — looks correct.
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.18.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.18 guide on main, in #28373.Changes from the main commit:
InvalidPayloadExceptionconstructor;camel-test-junit5in the new test.The 12 camel-github2 unit tests pass.
🤖 Generated with Claude Code