Skip to content

Conversation

@georgehao
Copy link
Member

@georgehao georgehao commented Nov 25, 2025

Purpose or design rationale of this PR

Fix issue where bridge-history-api fails to return results when a user has >500 pending withdrawals (see discussion).

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

    • Improved error handling for withdrawal query operations when no records are found.
  • Improvements

    • Increased the maximum number of withdrawal records that can be retrieved in a single query.
  • Version

    • Released version v4.7.2.

✏️ Tip: You can customize this high-level summary in your review settings.

@georgehao georgehao requested a review from Thegaram November 25, 2025 04:16
@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Walkthrough

This PR combines a version bump (v4.7.1 to v4.7.2) with two targeted improvements to the bridge history API: adding early error handling when no withdrawal records are found, and increasing the query result limit from 500 to 10000 records.

Changes

Cohort / File(s) Summary
Bridge History API Error Handling & Limits
bridge-history-api/internal/logic/history_logic.go, bridge-history-api/internal/orm/cross_message.go
Added early error return path in GetL2UnclaimedWithdrawalsByAddress when txHistoryInfos is empty; increased query limit from 500 to 10000 records
Version Bump
common/version/version.go
Updated version tag from "v4.7.1" to "v4.7.2"

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • The version bump is a straightforward single-line change
  • The limit increase is a single constant modification
  • The new error handling path is a simple conditional check; verify the error message and logging are appropriate
  • All changes are isolated and follow consistent patterns

Possibly related PRs

Suggested labels

bump-version

Suggested reviewers

  • Thegaram
  • yiweichi
  • colinlyguo

Poem

🐰 A version hops forth, from point-one to two,
With limits expanded and errors caught true,
Ten thousand records now dance in the light,
The bridge API sparkles, everything right! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive PR description follows the template structure with sections for purpose, PR title type, version tag, and breaking change status, though purpose rationale lacks detailed implementation explanation. Expand the 'Purpose or design rationale' section to explain what specific code changes were made, why the 500 limit was increased to 10000, and how the early error path in GetL2UnclaimedWithdrawalsByAddress prevents failures.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix bridge history GetL2UnclaimedWithdrawalsByAddress' follows conventional commits format with 'fix:' type and clearly describes the main change being fixed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/bridge_history_GetL2UnclaimedWithdrawalsByAddress

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.53%. Comparing base (9100a0b) to head (632cba7).

Files with missing lines Patch % Lines
bridge-history-api/internal/logic/history_logic.go 0.00% 4 Missing ⚠️
bridge-history-api/internal/orm/cross_message.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1760      +/-   ##
===========================================
- Coverage    36.54%   36.53%   -0.01%     
===========================================
  Files          247      247              
  Lines        21186    21190       +4     
===========================================
  Hits          7742     7742              
- Misses       12614    12618       +4     
  Partials       830      830              
Flag Coverage Δ
bridge-history-api 8.07% <0.00%> (-0.02%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bridge-history-api/internal/logic/history_logic.go (1)

94-103: Empty result is now treated as an error, which changes API semantics and breaks empty‑set caching

The new guard:

if len(txHistoryInfos) == 0 {
	log.Error("failed to get L2 claimable withdrawals by address len = 0", "address", address)
	return nil, 0, errors.New("unexpected error")
}

introduces two regressions:

  1. Semantics: Previously, “no unclaimed withdrawals” was a valid state: the method returned an empty slice and total=0. Now the same situation surfaces as an error, which will likely be exposed as a 5xx to clients, unlike GetL2WithdrawalsByAddress / GetTxsByAddress which still treat empty sets as success.

  2. Caching: With the early return, processAndCacheTxHistoryInfo is never called when the result is empty, so the "empty_page" placeholder is not written. For addresses with no unclaimed withdrawals, each call will miss the cache and re-hit the DB, defeating the existing empty-set caching optimization.

Unless there is a strong invariant that this function must always return at least one record (and callers are coded accordingly), this looks like a behavioral bug rather than a fix.

Consider reverting this guard, or at most keeping a log line but still flowing through to processAndCacheTxHistoryInfo and returning an empty slice on success:

-    if len(txHistoryInfos) == 0 {
-        log.Error("failed to get L2 claimable withdrawals by address len = 0", "address", address)
-        return nil, 0, errors.New("unexpected error")
-    }
+    if len(txHistoryInfos) == 0 {
+        log.Info("no L2 claimable withdrawals for address", "address", address)
+    }

This preserves existing API behavior and cache behavior while still giving visibility into unexpectedly empty cases via logs.

🧹 Nitpick comments (1)
bridge-history-api/internal/orm/cross_message.go (1)

151-165: Consider making the 10000 limit configurable and aligned with other query limits

Bumping the limit from 500 to 10000 makes sense for correctness on very active addresses, but it also increases worst‑case DB and Redis load for this path. It’s also now inconsistent with the 500 limits in GetL2WithdrawalsByAddress and GetTxsByAddress.

Consider:

  • Extracting this limit into a named constant (or config) rather than an inline 10000.
  • Reassessing whether 10000 is the right order of magnitude given expected per‑address volume and cache TTL.

This keeps the behavior change while making it easier to tune if load characteristics change.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9dceae1 and 805670d.

📒 Files selected for processing (3)
  • bridge-history-api/internal/logic/history_logic.go (1 hunks)
  • bridge-history-api/internal/orm/cross_message.go (1 hunks)
  • common/version/version.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: test
🔇 Additional comments (1)
common/version/version.go (1)

8-31: Version bump looks good; ensure external references are kept in sync

The bump of tag to v4.7.2 cleanly updates the computed Version string without changing any logic. Just make sure build/release metadata (git tags, changelogs, deployment configs) are aligned with this new version.

@georgehao georgehao merged commit 15a2347 into develop Nov 25, 2025
6 checks passed
@georgehao georgehao deleted the fix/bridge_history_GetL2UnclaimedWithdrawalsByAddress branch November 25, 2025 12:59
@coderabbitai coderabbitai bot mentioned this pull request Nov 25, 2025
13 tasks
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.

5 participants