Keep a bank's raw error text from failing the answer it rides on #5
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Nostro#5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When the bank, or something in front of it, answers an error with a body that is no JSON, nostro keeps the first 300 bytes of that body as the error's text. Those bytes need not be UTF-8, and D-Bus carries nothing else. The text then rides on an answer as a note, and the answer fails on it: a call that was carried out is answered
InvalidArgument, which every client reads as "refused, nothing was sent".Found by the pre-push review of 1.0.0 (the bug-prover lens). It is older than that release: the path is the same at 0.0.0.
Where
Links are to the tree at
8dd31e2(1.0.0).ErrorMessagefalls back tostd::string(body.substr(0, 300))for a body it cannot read as bunq's JSON. A cut at 300 bytes can split a character of a body that is UTF-8, and an error page in Latin-1 is not UTF-8 to begin with. The text ends up in theBunqError.what(): a connector that is unavailable when the connectors are read (Nostro-Connector.cpp:141, and again in the worker at:300), a logout that failed (:577), and a request for money that was made and could not be read back (Nostro-Bunq-Payments.cpp:272).Answerruns the call's work and then appends the notes, taking them out of the list first.Wire<std::string>::Appendthrowsstd::invalid_argument("text that is not UTF-8 cannot be sent to nostrod")when sd-bus refuses a string, andErrorForanswers that asInvalidArgument. The notes are gone with it.Concrete cases
BunqAccount::Requestposts the request, which bunq makes, and reads it back. The read gets a proxy's 502 page. The catch notes "request N was made, but reading it back failed: …" with the page's first 300 bytes and returns the request all the same, as it is meant to. The answer then fails on the note. The caller is toldInvalidArgument; the app shows "That cannot be done … Nothing was sent." Asking again asks twice.ErrorReplyhands the message tosd_bus_message_new_method_errorf. Its comment says that making an error answer fails only when memory runs out; with a message that is not UTF-8 it presumably fails as well, and the caller then waits for its own timeout, ten minutes by default.What it would take
dump's replace handler.ShouldMoveMoneyorShouldServeEveryUser: aFaulton the read-back of a request whose body is<html>with a byte that is no UTF-8, and the request's answer still arrives, with its note.What was run, and what was read
Run, against libsystemd 262.1:
sd_bus_message_append_basicwith typesreturns-EINVALfor a Latin-1 byte, for a three-byte character cut after its second byte, and for an over-long sequence. The rest is from reading the code at the commit above. Case 3 was not run, and no test fails on any of this today.