Skip to content

fix(bridge-history-api): bound request work and hide internal errors - #1825

Merged
Thegaram merged 1 commit into
developfrom
fix-bridge-history-api-request-limits
Oct 22, 2026
Merged

Thegaram merged 1 commit into
developfrom
fix-bridge-history-api-request-limits

Conversation

@Thegaram

@Thegaram Thegaram commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Purpose or design rationale of this PR

Tightens per-request limits in bridge-history-api. It also stops returning internal error details to clients.

Changes:

  • Query-only binding: the GET endpoints bind only the query string (ShouldBindQuery) and never read a request body.
  • Row cap: txsbyhashes DB queries are capped at 500 rows per table. A request that exceeds the cap returns an error, so partial results are never returned or cached.
  • Error text: internal errors return errmsg: "internal error". The full error is still logged. Validation errors are unchanged.
  • Cancellation: request cancellation now reaches DB and Redis calls (ContextWithFallback). A shared singleflight query keeps running when one caller disconnects, with a 10 s timeout.
  • Logging: the DB failure logs in GetTxsByHashes now include the error.
  • Bump version to v4.8.5.

PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • fix: A bug fix

Deployment tag versioning

Has tag in common/version.go been updated or have you added bump-version label to this PR?

  • No, this PR doesn't involve a new deployment, git tag, docker image tag
  • Yes

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • Bug Fixes
    • History lookups now read filters from query parameters consistently.
    • Unexpected lookup failures return a generic error rather than exposing internal details.
    • Shared history queries are bounded by a timeout, helping prevent prolonged requests when callers disconnect.
    • Hash-based message searches now return an error when results exceed 500, rather than returning partial results.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3b69ff93-5800-4ed4-93a8-b82ae7c4e18a
📥 Commits

Reviewing files that changed from the base of the PR and between 585b170 and fdd9d63.

📒 Files selected for processing: 10
  • bridge-history-api/cmd/api/app/app.go
  • bridge-history-api/internal/controller/api/controller.go
  • bridge-history-api/internal/controller/api/l2unclaimed_withdrawals_by_address.go
  • bridge-history-api/internal/controller/api/l2withdrawals_by_address.go
  • bridge-history-api/internal/controller/api/txs_by_address.go
  • bridge-history-api/internal/controller/api/txs_by_hashes.go
  • bridge-history-api/internal/logic/history_logic.go
  • bridge-history-api/internal/orm/bridge_batch_deposit.go
  • bridge-history-api/internal/orm/cross_message.go
  • common/version/version.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

The bridge history API now binds address lookup parameters from the query string and returns a generic error for history lookup failures. Shared queries use a 10-second timeout, and message queries reject results above their configured limits. The internal version tag changes to v4.8.5.

Changes: Bridge history API behavior

Layer / File(s) Summary
Request context and API responses
bridge-history-api/cmd/api/app/app.go, bridge-history-api/internal/controller/api/*
The router enables Gin context fallback. Address endpoints bind query parameters specifically. History lookup failures render internal error rather than the underlying error.
Shared query contexts and error logs
bridge-history-api/internal/logic/history_logic.go
Three singleflight database queries use contexts detached from caller cancellation and bounded by a 10-second timeout. Two lookup failure logs now include the returned error.
Message query result limits
bridge-history-api/internal/orm/bridge_batch_deposit.go, bridge-history-api/internal/orm/cross_message.go
The message queries fetch up to one row beyond their configured maximum and return an error when the maximum is exceeded.

Version tag

Layer / File(s) Summary
Update internal version tag
common/version/version.go
The internal version tag changes from v4.8.4 to v4.8.5.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: georgehao

Merge Risk: ⚪ Minimal · up to fdd9d

The reviewed changes present no verified merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title is concise, uses the conventional commit format, and accurately summarizes the main changes: bounding request work and hiding internal errors.
Description check Passed The description covers the purpose, implementation details, error handling, cancellation behavior, logging, version update, title convention, deployment tagging, and breaking-change status. It is comp…
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.
Full details: Description check

Explanation

The description covers the purpose, implementation details, error handling, cancellation behavior, logging, version update, title convention, deployment tagging, and breaking-change status. It is complete and consistent with the changes.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.55%. Comparing base (585b170) to head (fdd9d63).

Files with missing lines Patch % Lines
bridge-history-api/internal/logic/history_logic.go 0.00% 11 Missing ⚠️
...e-history-api/internal/orm/bridge_batch_deposit.go 0.00% 4 Missing ⚠️
bridge-history-api/internal/orm/cross_message.go 0.00% 4 Missing ⚠️
bridge-history-api/cmd/api/app/app.go 0.00% 2 Missing ⚠️
...ntroller/api/l2unclaimed_withdrawals_by_address.go 0.00% 2 Missing ⚠️
...nternal/controller/api/l2withdrawals_by_address.go 0.00% 2 Missing ⚠️
...tory-api/internal/controller/api/txs_by_address.go 0.00% 2 Missing ⚠️
...story-api/internal/controller/api/txs_by_hashes.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1825      +/-   ##
===========================================
- Coverage    35.58%   35.55%   -0.03%     
===========================================
  Files          263      263              
  Lines        22805    22824      +19     
===========================================
  Hits          8116     8116              
- Misses       13837    13856      +19     
  Partials       852      852              
Flag Coverage Δ
bridge-history-api 8.49% <0.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Thegaram
Thegaram merged commit 3046bbd into develop Oct 22, 2026
6 checks passed
@Thegaram
Thegaram deleted the fix-bridge-history-api-request-limits branch October 22, 2026 11:51
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