Describe the bug
When Claude Code Action downloads images from GitHub comments, it incorrectly determines the media type based on the file extension rather than the actual file content. This causes API errors when the actual image format differs from the extension.
The problematic image is ironically Claude's own spinner animation GIF that it adds to comments during processing.
To Reproduce
- Set up a workflow with
direct_prompt to trigger on PR open
- Claude starts processing and posts a comment with the spinner GIF:
<img src="https://github.com/user-attachments/assets/5ac382c7-e004-429b-8e35-7feb3e8f9c6f" />
- The action downloads the image and saves it as
/tmp/github-images/image-xxx-0.png
- Claude attempts to read the image file
- The image is sent to Claude API with
media_type: "image/png", but the actual data is GIF format
- API returns error:
Image does not match the provided media type image/png
Expected behavior
The action should detect the actual image format by inspecting the file content (magic bytes) rather than relying on the file extension or URL.
Screenshots
N/A
Workflow yml file
name: Claude PR Review
on:
pull_request:
types: [opened, synchronize]
jobs:
claude-review:
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude PR Review
uses: anthropics/claude-code-action@beta
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
direct_prompt: |
Please review this pull request and provide feedback on:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage
Be constructive and helpful in your feedback.
API Provider
[x] Anthropic First-Party API (default)
[ ] AWS Bedrock
[ ] GCP Vertex
Additional context
Error from logs:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.10.image.source.base64.data: Image does not match the provided media type image/png"},"request_id":"req_011CVVczVbPxv12AWe44tPoC"}
Relevant log showing the issue:
Downloading https://github.com/user-attachments/assets/5ac382c7-e004-429b-8e35-7feb3e8f9c6f...
✓ Saved: /tmp/github-images/image-1764119913494-0.png
The base64 data starts with R0lGOD, which is the GIF file signature, confirming the actual format is GIF, not PNG.
Describe the bug
When Claude Code Action downloads images from GitHub comments, it incorrectly determines the media type based on the file extension rather than the actual file content. This causes API errors when the actual image format differs from the extension.
The problematic image is ironically Claude's own spinner animation GIF that it adds to comments during processing.
To Reproduce
direct_promptto trigger on PR open<img src="https://github.com/user-attachments/assets/5ac382c7-e004-429b-8e35-7feb3e8f9c6f" />/tmp/github-images/image-xxx-0.pngmedia_type: "image/png", but the actual data is GIF formatImage does not match the provided media type image/pngExpected behavior
The action should detect the actual image format by inspecting the file content (magic bytes) rather than relying on the file extension or URL.
Screenshots
N/A
Workflow yml file
API Provider
[x] Anthropic First-Party API (default)
[ ] AWS Bedrock
[ ] GCP Vertex
Additional context
Error from logs:
Relevant log showing the issue:
The base64 data starts with
R0lGOD, which is the GIF file signature, confirming the actual format is GIF, not PNG.