Skip to content

fix: Correctly parse the limit/page pagination parameters when getting the logs emitted by a contract#79

Open
sonny-campbell wants to merge 1 commit into
evstack:mainfrom
sonny-campbell:bugfix/logs-pagination
Open

fix: Correctly parse the limit/page pagination parameters when getting the logs emitted by a contract#79
sonny-campbell wants to merge 1 commit into
evstack:mainfrom
sonny-campbell:bugfix/logs-pagination

Conversation

@sonny-campbell
Copy link
Copy Markdown
Contributor

@sonny-campbell sonny-campbell commented May 19, 2026

I set up a local chain through anvil and ran the atlas-server. I deployed a contract on the local chain and was trying to fetch the logs emitted by that contract with curl -s "localhost:3000/api/addresses/0xe7f1725e7734ce288f8367e1bb143e90bb3f0512/logs?limit=20"

Doing so triggered the following error:

$ curl -s "localhost:3000/api/addresses/0xe7f1725e7734ce288f8367e1bb143e90bb3f0512/logs?limit=20"
Failed to deserialize query string: invalid type: string "20", expected u32

It looks like the #[serde(flatten)] annotation on the LogsQuery doesn't play nicely with axum::extract::Query. The flatten attribute seems to keep the query parameters as strings internally, but the LogsQuery requires u32.

I've removed the Pagination field and flattened it in line to match TransactionLogsQuery

Summary by CodeRabbit

  • Refactor

    • Updated address logs endpoint to accept explicit page and limit query parameters for pagination.
  • Tests

    • Extended test coverage for address logs query parameter parsing.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf790935-b27e-4b64-b4ec-dbf197d5bf91

📥 Commits

Reviewing files that changed from the base of the PR and between c36eee2 and 4da3cda.

📒 Files selected for processing (1)
  • backend/crates/atlas-server/src/api/handlers/logs.rs

📝 Walkthrough

Walkthrough

The LogsQuery struct for the address logs endpoint is refactored to replace a flattened Pagination struct with explicit page and limit query parameters. The handler's pagination metadata wiring is updated to match, and tests verify the new query parsing behavior.

Changes

Address Logs Pagination Refactoring

Layer / File(s) Summary
LogsQuery struct and handler wiring
backend/crates/atlas-server/src/api/handlers/logs.rs
LogsQuery replaces flattened Pagination with explicit page and limit fields, each with serde defaults. Imports adjusted to remove the Pagination type. Handler's get_address_logs updated to pass query.page directly to PaginatedResponse::new.
Query parsing test coverage
backend/crates/atlas-server/src/api/handlers/logs.rs
New unit test verifies LogsQuery parses page and limit from a query string and correctly computes limit() and offset() values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • tac0turtle

Poem

🐰 A query hops lighter now, fields spread wide and clear,
No nested structs to tunnel through—pagination drawing near!
With page and limit dancing free, the handler sees the way,
Tests hop along to verify: defaults work today! 📋

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 directly and accurately describes the main change: fixing pagination parameter parsing for contract logs by refactoring LogsQuery to use explicit page/limit parameters instead of a flattened Pagination struct.
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 unit tests (beta)
  • Create PR with unit tests

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.

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