Skip to content

Comments

fix 502 on invalid limit params in tx query endpoints#24

Open
Liusher wants to merge 2 commits intomainfrom
fix/api-limit-validation
Open

fix 502 on invalid limit params in tx query endpoints#24
Liusher wants to merge 2 commits intomainfrom
fix/api-limit-validation

Conversation

@Liusher
Copy link
Contributor

@Liusher Liusher commented Feb 18, 2026

Summary

  • GET /api/chain/tx_events_by_account/ and GET /api/chain/tx_by_filter were calling :erlang.binary_to_integer on user-supplied query params without validation
  • Invalid values (non-integer strings, floats) caused a badarg exception that crashed the handler process → 502 response
  • Negative values were silently accepted and passed to DB/NIF layer causing undefined behaviour

Fix

Replaced :erlang.binary_to_integer with Integer.parse/1 and added guards (>= 0) on both endpoints. Invalid or negative limit/offset now return 400 {error: "invalid_parameters"}.

Test plan

  • GET /api/chain/tx_events_by_account/<addr>?limit=abc → 400
  • GET /api/chain/tx_events_by_account/<addr>?limit=-1 → 400
  • GET /api/chain/tx_events_by_account/<addr>?offset=-5 → 400
  • GET /api/chain/tx_by_filter?limit=abc → 400
  • GET /api/chain/tx_by_filter?limit=-1 → 400
  • Valid requests still work as before

🤖 Generated with Claude Code

Dev and others added 2 commits February 18, 2026 16:28
/api/upow/seed:                 max 10 req/min per IP
/api/upow/seed_with_matrix_a_b: max 2 req/min per IP (16MB response)

Returns HTTP 429 when limit exceeded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace :erlang.binary_to_integer with Integer.parse in
tx_events_by_account and tx_by_filter handlers so invalid
or negative limit/offset values return 400 instead of crashing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor Author

@Liusher Liusher left a comment

Choose a reason for hiding this comment

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

b

Liusher

This comment was marked as duplicate.

@vans163
Copy link
Member

vans163 commented Feb 19, 2026

rebase your branch.
image

these changes are already on main. please remove them from this PR

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.

3 participants