taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

serialization-error-shown-to-the-cashier.md (3808B)


      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 missing field is reported to the cashier by its Kotlin type name
     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 backend reply that is missing a field the terminal needs puts this on the
     22 counter:
     23 
     24 ```
     25 Error fetching the order history
     26 Illegal input: Field 'orders' is required for type with serial name
     27 'net.taler.merchantlib.OrderHistory', but it was missing at path: $
     28 ```
     29 
     30 That is kotlinx.serialization's own wording, shown verbatim. It names a Kotlin
     31 class, a serial name and a JSON path, none of which mean anything to the person
     32 holding the till, and it does not say the one thing that does: the backend sent
     33 something the terminal could not read, and retrying or checking the backend is
     34 what to do about it.
     35 
     36 ## Why it happens
     37 
     38 `merchant-lib/src/main/java/net/taler/merchantlib/Response.kt`:
     39 
     40 ```kotlin
     41 private suspend fun getFailureString(failure: Failure): String =
     42     when (val exception = failure.exception) {
     43         is ResponseException -> getExceptionString(exception)
     44         is UnknownHostException, ... -> NETWORK_ERROR_MESSAGE
     45         is IOException -> exception.message?.takeIf(String::isNotBlank)
     46             ?: NETWORK_ERROR_MESSAGE
     47         else -> exception.message?.takeIf(String::isNotBlank)
     48             ?: exception.toString()
     49     }
     50 ```
     51 
     52 A `SerializationException` is none of the named types, so it takes the `else`
     53 arm and its `message` goes straight to the dialog. The status was 200 and the
     54 body was JSON; only its *shape* was wrong, which is the one failure mode that
     55 has no sentence of its own.
     56 
     57 This is the same arm that
     58 [a cut connection](transport-error-shows-the-library-wording.md) reaches, and
     59 the two want the same kind of fix: a sentence the terminal owns, with the
     60 library's text kept for the log rather than the screen.
     61 
     62 ## How it was found
     63 
     64 `taler-twister` in front of the real demo backend, asked to delete one field
     65 from the next reply:
     66 
     67 ```python
     68 c.tw.delete("orders")
     69 c.app.tap_button(r"Refresh history")
     70 ```
     71 
     72 Scenario: `fault_history_unreadable`, which does this three ways -- a truncated
     73 body, a deleted field, and a character flipped inside a string value. The third
     74 is the interesting one for a different reason: the JSON still parses, so
     75 nothing throws and whatever the terminal draws it draws from a value that is
     76 wrong.
     77 
     78 Nothing a correctly behaving backend sends can reach this, and the mock cannot
     79 produce it either without being written to send a reply it believes in -- which
     80 is why it took a proxy over a real exchange.
     81 
     82 ## Severity
     83 
     84 Low to medium, and the same judgement as the cut-connection case: nothing is
     85 lost, the next refresh works. What is wrong is that an internal type name is
     86 the error message. It also tells anyone looking over the counter what the app
     87 is built out of, which is not a serious disclosure but is not nothing either.
     88 
     89 ## Suggested fix
     90 
     91 Give the deserialization failure its own arm, next to the network one:
     92 
     93 ```kotlin
     94 is SerializationException -> MALFORMED_REPLY_MESSAGE
     95 ```
     96 
     97 with the exception's own text logged rather than displayed.