Skip to content

[backport camel-4.18.x] CAMEL-25983: camel-github2 - getCommitFile reads the file of the commit - #28374

Merged
davsclaus merged 2 commits into
camel-4.18.xfrom
backport/CAMEL-25983-github2-to-camel-4.18.x
Oct 25, 2026
Merged

davsclaus merged 2 commits into
camel-4.18.xfrom
backport/CAMEL-25983-github2-to-camel-4.18.x

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

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 CamelGitHubCommitSha header, which must be a commit id of 40 hexadecimal characters. The path comes from the new CamelGitHubFilePath header, 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:

  • the 3-argument InvalidPayloadException constructor;
  • camel-test-junit5 in the new test.

The 12 camel-github2 unit tests pass.

🤖 Generated with Claude Code

Backport of the camel-github2 part of #28373 to camel-4.18.x.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@davsclaus davsclaus added this to the 4.18.6 milestone Oct 23, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@davsclaus davsclaus self-assigned this Oct 25, 2026
@davsclaus davsclaus added the bug Something isn't working label Oct 25, 2026
@davsclaus
davsclaus merged commit 16bbc3a into camel-4.18.x Oct 25, 2026
3 checks passed
@davsclaus
davsclaus deleted the backport/CAMEL-25983-github2-to-camel-4.18.x branch October 25, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants