Skip to content

Validate v2 API boolean parameters#3378

Closed
caydyan wants to merge 1 commit into
CounterpartyXCP:masterfrom
caydyan:fix-api-bool-param-validation
Closed

Validate v2 API boolean parameters#3378
caydyan wants to merge 1 commit into
CounterpartyXCP:masterfrom
caydyan:fix-api-bool-param-validation

Conversation

@caydyan

@caydyan caydyan commented Jun 9, 2026

Copy link
Copy Markdown

Summary

This validates v2 API boolean query parameters instead of silently coercing unsupported values to false.

Currently, prepare_args() parses booleans with str_arg.lower() in ["true", "1"], so any unsupported value becomes False. For example:

  • /v2/transactions?show_unconfirmed=maybe returns 200 OK
  • /v2/transactions?verbose=maybe is accepted and treated as non-verbose

The fix accepts only true, 1, false, and 0 for boolean route arguments and returns the existing 400 API error path for unsupported values. It also validates the shared non-compose verbose query parameter before executing the route.

Tests

  • .venv/bin/pytest counterpartycore/test/units/api/apiserver_test.py::test_invalid_bool_param_rejected -q
  • .venv/bin/pytest counterpartycore/test/units/api/apiserver_test.py -q
  • .venv/bin/ruff check counterpartycore/lib/api/apiserver.py counterpartycore/test/units/api/apiserver_test.py
  • .venv/bin/ruff format --check counterpartycore/lib/api/apiserver.py counterpartycore/test/units/api/apiserver_test.py
  • git diff --check

If this qualifies for the project bounty program, BTC payout address:
bc1qev5ant33v5y89qqjvcf4mh9hlax5svqf5xd7gc

@caydyan

caydyan commented Jun 10, 2026

Copy link
Copy Markdown
Author

Closing this master-based PR in favor of the develop-based replacement #3420: #3420

@caydyan caydyan closed this Jun 10, 2026
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