fix: return image/apng media type from animated card endpoint (#196) #204
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#204
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/196-bug-apng-endpoint-returns-wrong-media-type-image-p"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #196
Summary
The animated card endpoint (
GET /{player_id}/{card_type}card/{d}/{variant}/animated) was returningFileResponsewithmedia_type="image/png". APNG files are technically valid PNG, but Discord and browser clients use the MIME type to decide whether to animate the content —image/pngmay cause the file to be treated as a static image.Change
app/routers_v2/players.pyline 863:"image/png"→"image/apng"Files Changed
app/routers_v2/players.pyTests
No test suite applies to this change. Verified by reading back the modified line.
AI Code Review
Files Reviewed
app/routers_v2/players.py(modified)Findings
Correctness
BLOCKING: The fix is incomplete.
get_animated_cardhas twoFileResponsereturn paths, and only one was updated.The cache hit path at line 773 still returns
media_type="image/png". Since cards are cached after first render, the vast majority of production requests go through the cache hit path — meaning the MIME type fix will almost never be seen by clients. Both lines must return"image/apng".Security
Style & Conventions
Verdict: REQUEST_CHANGES (posted as COMMENT — self-review restriction)
The change correctly identifies
image/apngas the right MIME type, but misses the cache hit return at line 773. Fix that line to match and the PR is ready to merge.Automated review by Claude PR Reviewer
BLOCKING: This cache-hit return path also needs
media_type="image/apng". It serves the same APNG file but still returns the wrong MIME type. Since most production requests hit this path after first render, the fix at line 863 will almost never take effect.Addressed review feedback: updated the cache hit path at line 773 to return
media_type="image/apng"(matching the cache miss path at line 863). BothFileResponsereturn paths inget_animated_cardnow correctly returnimage/apng.AI Code Review
Files Reviewed
app/routers_v2/players.py(modified)Findings
Correctness
FileResponsereturn paths inget_animated_cardare now fixed:"image/png"→"image/apng"✅"image/png"→"image/apng"✅Security
Style & Conventions
Suggestions
Verdict: APPROVED (posted as COMMENT — self-review restriction)
Both
FileResponsereturn paths inget_animated_cardnow correctly useimage/apng. The prior blocking issue is resolved. Ready to merge.Automated review by Claude PR Reviewer
Approved via pd-pr