Skip to content

fix: accept null optional params in make_invoice and list_transactions - #54

Open
PatMulligan wants to merge 1 commit into
lnbits:mainfrom
PatMulligan:fix/null-optional-params
Open

PatMulligan wants to merge 1 commit into
lnbits:mainfrom
PatMulligan:fix/null-optional-params

Conversation

@PatMulligan

Copy link
Copy Markdown

Clients may send optional params as an explicit JSON null rather than omitting them; Amethyst does this for description, description_hash and expiry. dict.get only applies its default for a missing key, so description arrived as None and make_invoice failed with 'NoneType' object has no attribute 'encode'.

This coerces with or instead, passes no unhashed_description when the description is blank, and applies the same to list_transactions' paging params, which had the same exposure. Three unit tests cover the fields omitted, sent as null, and set; the null case reproduces the error on main.

Clients may send optional params as an explicit JSON null rather than
omitting them; Amethyst does for description, description_hash and
expiry. dict.get only applies its default for a missing key, so
description arrived as None and make_invoice failed with
"'NoneType' object has no attribute 'encode'".

Coerce with `or` instead, pass no unhashed_description when the
description is blank, and apply the same to list_transactions' paging
params, which had the same exposure.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
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