Skip to content

feat(fetcher): add random_dog — random dog photo from dog.ceo - #192

Merged
unhappychoice merged 1 commit into
mainfrom
feat/random-dog-fetcher
Apr 29, 2026
Merged

unhappychoice merged 1 commit into
mainfrom
feat/random-dog-fetcher

Conversation

@unhappychoice

Copy link
Copy Markdown
Owner

Summary

  • Image-only fetcher that downloads a random dog photo from dog.ceo each refresh cycle and exposes it as Body::Image. Caches to $SPLASHBOARD_HOME/cache/dogs/<key>.<ext>.
  • Safety::Safe: both the API host (dog.ceo) and the CDN host (images.dog.ceo) are hardcoded; no auth, no token to leak. Mirrors random_cat's fixed-host stance from project_trust_model.md.
  • Two-step flow (JSON endpoint → image URL → image bytes). The URL returned by the API is re-validated against an allowlist so a future API change can't hand us an off-host SSRF primitive.
  • Optional breed / sub_breed filters. Validation rejects sub_breed without breed.
  • Adds the random_dog row to meta: fetcher roadmap - Social & Media #67 Novelty image feeds (new entry — was not previously catalogued).

Reference

Kind Safety Shapes
cached Safe image

Options

Option Type Required Default Description
breed string no — dog.ceo breed slug (e.g. shiba, husky, golden). Omit for any breed.
sub_breed string no — dog.ceo sub-breed slug (e.g. cocker under breed = "spaniel"). Requires breed.

Compatible renderers

Shape Renderers
image animated_boot, animated_postfx, animated_scanlines, animated_splitflap, animated_wave, media_image

Implementation notes

  • dog.ceo API returns {"message": "<image url>", "status": "success"}. Image URLs are hosted on images.dog.ceo. The two-call structure differs from random_cat's single-call cataas redirect, but the fetcher surface stays identical (Image-only, magic-byte detection, stale-extension cleanup, 5 MB cap).
  • Host allowlist (images.dog.ceo / dog.ceo) is enforced even though dog.ceo currently only points there — defensive against an upstream pivot.
  • Validation pre-checks sub_breed requires breed before issuing the request, so the user gets a clear error rather than a 404 from a /breed//cocker/... URL.
  • Path segments are percent-encoded so an unusual breed string can't break URL parsing.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test (1247 green; +20 new unit tests for random_dog)
  • cargo xtask regenerates docs-site/src/content/docs/reference/fetchers/random/random_dog.md cleanly
  • Smoke-tested locally with media_image (default / breed = shiba / breed = spaniel + sub_breed = cocker) — three dogs render side by side
  • Live test (downloads a real dog): cargo test -- --ignored fetcher::random_dog::tests::live --nocapture

🤖 Generated with Claude Code

Image-only fetcher mirroring `random_cat`. Two-step flow: GET dog.ceo JSON
endpoint, extract image URL, then GET image bytes. Host of the returned
URL is re-validated against an allowlist (`images.dog.ceo` / `dog.ceo`) so
a future API change can't redirect us to an attacker-controlled origin.

Safety::Safe — both API and CDN hosts are hardcoded; no auth. Magic-byte
format detection (PNG / JPEG / GIF / WebP), stale-extension cleanup, 5 MB
body cap, all matching `random_cat`.

Options:
- `breed`     — narrow to a dog.ceo breed slug (e.g. `shiba`, `husky`).
- `sub_breed` — sub-breed under `breed` (e.g. `cocker` under `spaniel`).
                Validation rejects `sub_breed` without `breed`.

Adds the catalog row to #67 Novelty image feeds (no prior checkbox; new
entry alongside `random_cat`).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@unhappychoice has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 39 minutes before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea1d0939-58c5-4bb3-b5fe-52f541c51cb4

📥 Commits

Reviewing files that changed from the base of the PR and between 6796bae and d61e2c4.

📒 Files selected for processing (2)
  • src/fetcher/mod.rs
  • src/fetcher/random_dog.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/random-dog-fetcher

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 39 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.04110% with 105 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.62%. Comparing base (6796bae) to head (d61e2c4).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/fetcher/random_dog.rs 63.91% 105 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #192      +/-   ##
==========================================
- Coverage   81.72%   81.62%   -0.10%     
==========================================
  Files         140      141       +1     
  Lines       29690    29982     +292     
==========================================
+ Hits        24264    24473     +209     
- Misses       5426     5509      +83     
Files with missing lines Coverage Δ
src/fetcher/mod.rs 85.05% <100.00%> (+0.04%) ⬆️
src/fetcher/random_dog.rs 63.91% <63.91%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@unhappychoice
unhappychoice merged commit abbd71a into main Apr 29, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/random-dog-fetcher branch April 29, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant