Skip to content

fix: API hardening for bridge-history and shared metrics - #1823

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

Thegaram merged 1 commit into
developfrom
fix-bridge-history-api-paging-hardening

Conversation

@Thegaram

@Thegaram Thegaram commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Purpose or design rationale of this PR

Hardens request handling in bridge-history-api and bounds label values in the shared gin metrics middleware.

Changes:

  • Metrics (common/observability/ginmetrics): the method label accepts only standard HTTP methods; any other value is recorded as OTHER. This keeps the number of metric series bounded. This also affects coordinator-api and coordinator-proxy.
  • Server timeouts (bridge-history-api/cmd/api): serve through an http.Server with ReadHeaderTimeout 10s and ReadTimeout 30s, instead of router.Run with no timeouts.
  • Pagination (types/schema.go): cap page at 10000. Larger values overflowed (page-1)*page_size and returned the wrong page. Address queries return at most 10000 rows, so no reachable page is lost.
  • Cache (logic/history_logic.go): a cache miss right after a write now returns an error instead of an empty success.
  • Bump version to v4.8.3.

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

  • API Changes
    • Address-based history queries now accept page numbers from 1 to 10,000. Requests outside this range are rejected.
  • Reliability
    • The API server now applies timeouts when reading request headers and request bodies, helping prevent requests from occupying server resources indefinitely. These limits may affect clients that send requests too slowly.

@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: 0673adf2-9a4b-44a1-9226-7119b2d8e6e6
📥 Commits

Reviewing files that changed from the base of the PR and between a5d61e4 and fdfaab5.

📒 Files selected for processing: 5
  • bridge-history-api/cmd/api/app/app.go
  • bridge-history-api/internal/logic/history_logic.go
  • bridge-history-api/internal/types/schema.go
  • common/observability/ginmetrics/middleware.go
  • common/version/version.go

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

📝 Walkthrough

The bridge-history API now starts through a configured http.Server, limits page values to 10,000, and returns a fixed error after a post-write cache miss. Gin metrics normalize nonstandard HTTP methods to OTHER. The package version tag changes to v4.8.3.

Changes: Bridge history API

Layer / File(s) Summary
HTTP server startup
bridge-history-api/cmd/api/app/app.go
The router now runs through an http.Server with a 10-second ReadHeaderTimeout and a 30-second ReadTimeout.
Page validation
bridge-history-api/internal/types/schema.go
QueryByAddressRequest.Page accepts values from 1 through 10,000.
Post-write cache miss
bridge-history-api/internal/logic/history_logic.go
A cache miss after a write now returns "cache miss after write" instead of the cache lookup error.

Gin metric method labels

Layer / File(s) Summary
Normalize metric method labels
common/observability/ginmetrics/middleware.go
URI-request and slow-request metrics use the standard HTTP method names or OTHER for other methods.

Package version

Layer / File(s) Summary
Update version tag
common/version/version.go
The package version tag changes from v4.8.2 to v4.8.3.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: colinlyguo, georgehao

Merge Risk: ⚪ Minimal · up to fdfaa

The scoped API hardening and observability changes have no identified 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 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 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 required conventional commit type, and accurately summarizes the API hardening and shared metrics changes.
Description check Passed The description includes the required purpose, PR title, deployment tag versioning, and breaking change sections. It explains what changed, why the changes were made, and how they address the stated o…
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 includes the required purpose, PR title, deployment tag versioning, and breaking change sections. It explains what changed, why the changes were made, and how they address the stated objectives.

✨ 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

codecov-commenter commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.53%. Comparing base (a5d61e4) to head (fdfaab5).

Files with missing lines Patch % Lines
common/observability/ginmetrics/middleware.go 0.00% 8 Missing ⚠️
bridge-history-api/cmd/api/app/app.go 0.00% 7 Missing ⚠️
bridge-history-api/internal/logic/history_logic.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1823      +/-   ##
===========================================
- Coverage    35.56%   35.53%   -0.03%     
===========================================
  Files          263      263              
  Lines        22751    22763      +12     
===========================================
- Hits          8091     8089       -2     
- Misses       13811    13824      +13     
- Partials       849      850       +1     
Flag Coverage Δ
bridge-history-api 7.98% <0.00%> (-0.02%) ⬇️
common 31.35% <0.00%> (-0.07%) ⬇️
coordinator 28.56% <ø> (-0.07%) ⬇️
database 36.24% <ø> (ø)
rollup 35.59% <ø> (ø)

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 398e90b into develop Oct 22, 2026
18 checks passed
@Thegaram
Thegaram deleted the fix-bridge-history-api-paging-hardening branch October 22, 2026 09:09
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