Cash-in-only machines never report cassette state, and an empty positions map would corrupt or crash the consumer #48
Loading…
Add table
Add a link
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?
Found while bringing up a Raspberry Pi 4 with a Pyramid Apex acceptor and no dispenser. Two problems, one in each direction.
The UI waits forever and blames the wrong thing
The cassettes section for the machine shows:
The ATM is powered on and has demonstrably reached the relay — it pulled its fee config over that same transport minutes earlier. The wait is not about connectivity, and the suggested remedy cannot fix it.
Cause is on the bitspire side. The
rpi4preset shipscassettes: [], thecassettestable instate.dbstays empty, andpublishCassettesStatereturns early:So nothing is ever published. For a machine with no dispenser that is arguably correct behaviour, but the operator cannot tell it apart from a machine that is offline.
Making the ATM report empty would break this consumer
The obvious fix is for a cash-in-only machine to publish
{"positions": {}}so the operator learns it is alive and has no bays. That currently lands on a latent bug.consume_cassette_state_eventincrud.pybuilds the delete list from the payload keys:With no positions,
placeholdersis empty and the statement becomesposition NOT IN (). That behaves differently per backend, and both are wrong:NOT IN ()is true for every row, so every cassette row for that machine is deleted. Verified locally.PublishCassettesPayload.positionsis a plaindict[int, CassettePayloadRow]with no minimum length, so validation does not catch it first.Suggested shape
NOT INclause entirely, rather than relying on the payload never being empty. This is worth doing regardless of the rest, since a shrinking bay count reaching zero hits the same path.Related: #47 covers the operator-side republish heartbeat, which is a different direction of the same conversation.