anthropics / anthropics/claude-code-action
Bug: Image media type detection fails for GIF images saved with .png extension
- Ngôn ngữ chính
- TypeScript
- Star
- 8.9k
- Fork
- 2.1k
- Merge trung bình
- 3 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 10
Mô tả
**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**
1. Set up a workflow with `direct_prompt` to trigger on PR open
2. Claude starts processing and posts a comment with the spinner GIF: ``
3. The action downloads the image and saves it as `/tmp/github-images/image-xxx-0.png`
4. Claude attempts to read the image file
5. The image is sent to Claude API with `media_type: "image/png"`, but the actual data is GIF format
6. 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**
```yaml
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.
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.