transport-error-shows-the-library-wording.md (3893B)
1 <!-- 2 This file is part of GNU Taler 3 (C) 2026 Taler Systems S.A. 4 5 GNU Taler is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 --> 16 17 # A connection that dies mid-response is reported in the HTTP engine's words 18 19 > **Fixed on master** (checked 2026-11-08, commit `24f7b249`). See [STATUS.md](STATUS.md) for the fix and the test that pins it. 20 21 A cashier refreshing the order history over a connection that closes halfway 22 through the reply is shown 23 24 ``` 25 Error fetching the order history 26 unexpected end of stream 27 ``` 28 29 "unexpected end of stream" is OkHttp's phrasing of a truncated HTTP/1.1 30 response. It is not a sentence anybody wrote for a cashier, it names nothing 31 the cashier can act on, and `merchant-lib` already has the sentence that 32 should be there. 33 34 ## Why it happens 35 36 `merchant-lib/src/main/java/net/taler/merchantlib/Response.kt`: 37 38 ```kotlin 39 private suspend fun getFailureString(failure: Failure): String = 40 when (val exception = failure.exception) { 41 is ResponseException -> getExceptionString(exception) 42 is UnknownHostException, 43 is UnresolvedAddressException, 44 is ConnectException, 45 is SocketTimeoutException -> NETWORK_ERROR_MESSAGE 46 is IOException -> exception.message?.takeIf(String::isNotBlank) 47 ?: NETWORK_ERROR_MESSAGE 48 else -> ... 49 } 50 ``` 51 52 Four exception types get `NETWORK_ERROR_MESSAGE` -- "Network error: check your 53 internet connection and merchant URL." Every *other* `IOException` prefers 54 `exception.message`, and a truncated response is exactly that: an 55 `IOException` whose message comes from the engine. The four that are named are 56 the four that happen *before* any bytes arrive; the ones that happen in the 57 middle of a transfer are the ones that fall through. 58 59 The arm is not dead code to be deleted -- some `IOException` messages are worth 60 showing. But the ordering is the wrong way round for the commonest member of 61 the class. 62 63 ## How it was found 64 65 `driver/faults.py`'s TLS front, which terminates TLS in front of 66 `taler-twister` so the terminal can reach it at all, also injects what twister 67 has no notion of because it happens below HTTP. Its `cut` mode forwards the 68 response headers and then closes the connection partway through the body: 69 70 ```python 71 with c.front.transport("cut"): 72 c.app.tap_button(r"Refresh history") 73 ``` 74 75 Scenario: `fault_login_connection_cut`. 76 77 Nothing else in the harness reaches this. A status code lands in 78 `getExceptionString`; an unreachable host raises `ConnectException`, which is 79 one of the four that are named; a backend that never answers raises 80 `SocketTimeoutException`, which is another. Only a transfer that starts and 81 does not finish gets here. 82 83 ## Severity 84 85 Low to medium. Nothing is lost and the retry works -- the scenario checks that 86 the next refresh fills the list again, and it does. What is wrong is the 87 message: a cashier on a flaky counter network sees a phrase from an HTTP 88 library instead of being told to check the network, which is the whole point of 89 having the string. 90 91 ## Suggested fix 92 93 Treat a mid-transfer `IOException` as a network error, and keep the message 94 only where it adds something: 95 96 ```kotlin 97 is IOException -> NETWORK_ERROR_MESSAGE 98 ``` 99 100 or, if an engine message is worth keeping for the unusual cases, put 101 `NETWORK_ERROR_MESSAGE` in front of it rather than behind it.