Skip to content

Validate v2 API boolean parameters#3420

Open
caydyan wants to merge 1 commit into
CounterpartyXCP:developfrom
caydyan:fix-api-bool-param-validation-develop
Open

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

Conversation

@caydyan

@caydyan caydyan commented Jun 10, 2026

Copy link
Copy Markdown

Supersedes #3378 with the same fix rebased onto the current develop branch.

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 can be accepted instead of returning a clear parameter error.

Details:

  • Accepts only true, 1, false, and 0 for boolean route arguments.
  • Returns the existing API 400 error path for unsupported boolean values.
  • Validates the shared non-compose verbose query parameter before route execution.

Tests:

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

Bounty payment address (BTC): bc1qev5ant33v5y89qqjvcf4mh9hlax5svqf5xd7gc

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