Skip to content

fix: add User-Agent to MetadataFetcher HTTP client to prevent CDN 403s#68

Merged
pthmas merged 2 commits intomainfrom
issue-65
Apr 22, 2026
Merged

fix: add User-Agent to MetadataFetcher HTTP client to prevent CDN 403s#68
pthmas merged 2 commits intomainfrom
issue-65

Conversation

@pthmas
Copy link
Copy Markdown
Collaborator

@pthmas pthmas commented Apr 22, 2026

Summary

Adds .user_agent("atlas-server/0.1.0") to the reqwest client in MetadataFetcher::new. CDNs serving NFT metadata (IPFS gateways, OpenSea, etc.) classify requests with no User-Agent as bots and return 403, causing image_url to stay null and images to be blank.

Summary by CodeRabbit

Release Notes

  • Refactor
    • Enhanced HTTP request header configuration for improved standards compliance
    • Optimized database connection parameter validation logic

@pthmas pthmas self-assigned this Apr 22, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

📝 Walkthrough

Walkthrough

Two minor changes to the backend HTTP client and database configuration: explicit User-Agent header added to outbound HTTP requests, and query parameter parsing logic simplified via pattern guard refactoring.

Changes

Cohort / File(s) Summary
HTTP Client Configuration
backend/crates/atlas-server/src/indexer/metadata.rs
Added explicit User-Agent header ("atlas-server/0.1.0") to reqwest::Client builder in MetadataFetcher::new.
Database Connection Parsing
backend/crates/atlas-server/src/main.rs
Simplified dbname query parameter pattern matching from nested conditional to single guard-based pattern, preserving non-empty value semantics.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

Poem

🐰 A User-Agent hops along,
Identifying requests strong,
While patterns dance in guards so neat,
Two simple changes, clean and sweet!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a User-Agent header to prevent CDN 403 errors, which is the primary focus of the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-65

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

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@backend/crates/atlas-server/src/indexer/metadata.rs`:
- Around line 47-51: Add a unit test in a #[cfg(test)] mod tests block in the
same metadata.rs file that asserts the new User-Agent behavior: instantiate or
exercise the code path that creates the reqwest::Client (the client variable
built with .user_agent("atlas-server/0.1.0")) and verify that outgoing requests
include the "User-Agent: atlas-server/0.1.0" header (or that the client's
default headers contain that value); name the test clearly (e.g.,
test_user_agent_header) and keep it runnable with cargo test --workspace to
prevent regressions of the request-header logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: acad398a-9c9e-4fb4-baa1-195c17fbe7b5

📥 Commits

Reviewing files that changed from the base of the PR and between cf9cabb and 84947cb.

📒 Files selected for processing (2)
  • backend/crates/atlas-server/src/indexer/metadata.rs
  • backend/crates/atlas-server/src/main.rs

Comment thread backend/crates/atlas-server/src/indexer/metadata.rs
@pthmas pthmas requested a review from tac0turtle April 22, 2026 09:36
@pthmas pthmas merged commit d493e20 into main Apr 22, 2026
10 checks passed
@pthmas pthmas deleted the issue-65 branch April 22, 2026 09:57
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.

2 participants