ananthakumaran/paisa

error messages sometimes list of integers

samuelallan72 opened this issue ยท 8 comments

Describe your Environment
OS: Ubuntu 23.04
Paisa Version: 0.6.2
App Variant: CLI

Describe the bug

With my hledger ledger, paisa fails to sync the journal. It outputs an error message at some assertion transactions (which could be the subject of another bug report, but I'm more interested in the error message right now. The error message is output as a list of integers, instead of a message. For example:

$ paisa update
INFO    Using config file: /home/ubuntu/...
INFO    Syncing transactions from journal
ERROR   {[104 108 101 100 103 101 114 58 32 69 114 114 111 114 58 32 47 104 111 109 101 47 117 98 117 110 116 117 ...] 0 0}

Converting the numbers to ascii reveals the error message. (example clipped for privacy)

I cannot reproduce with a more minimal example - eg. if I add a failing assertion to the default main.ledger created from paisa init. In these cases, it successfully prints the hledger error output as expected.

To Reproduce
Steps to reproduce the behavior:

This seems specific to my ledger, which I'm not willing to share due to privacy concerns sorry.

Expected behavior

The error message from hledger displayed in a readable manner.

could you run $ PAISA_DEBUG=true paisa update and share the error log, this will include the filename, line number, and function name in the log which will help me figure out where the error log comes from.

Sure! Here it is:

ERROR   [ledger.go:731] execHLedgerCommand {[104 108 101 100 103 101 114 58 32 69 114 114 111 ...] 0 0}
FATAL   [update.go:28] func3 exit status 1

The decoded error message from hledger looks like this (obfuscated for privacy):

hledger: Error: /home/ubuntu/.../ledger:100:44:
      | 2020-01-01 * assert balance
100 |     assets:bank           0 AUD == 1234.56 AUD
      |                                                     ^^^^^^^^^^^^^^^

This balance assertion failed.
In account:    assets:bank
and commodity: AUD                             (no other commodities allowed)
this balance was asserted:     1234.56
but the calculated balance is: 7890.12

To troubleshoot, you can view this account's running balance. Eg:

hledger reg 'assets:bank$' -I  # -f FILE

And hledger version:

โฏ hledger --version
hledger 1.32.2, linux-x86_64

I would be curious to see the exact call to hledger, because my ledger doesn't have any failing assertions when I use it directly with hledger.

EDIT: the failing call is:

hledger -f /home/ubuntu/.../ledger --auto print -Ojson --forecast=2021..2027 tag:_generated-transaction

With the failing call:

hledger -f /home/ubuntu/.../ledger --auto print -Ojson --forecast=2021..2027 tag:_generated-transaction

I guess the issue is that it's outputting all the generated transactions from the periodic transactions I've used for budgeting, and they're not exact with reality of course, so the balance assertion fails. It's strange that this throws off the assertion - I'm not sure if this is an issue with how paisa is calling hledger, or in hledger itself.

does it work if you include --ignore-assertions flag to the hledger call? There are two independent issues here

  1. The error should show the error message instead of list of numbers, I will debug this
  2. I am not sure about the assertion failure, but I am ok to relax this for forecast transactions. Paisa will export all the future transactions using the --forecast flag. Since I am only interested in the forecast transactions, I can ignore assertion failure. If possible, try to check with hledger folks, because I don't know if it's supposed to use forecasted transactions for assertion.

does it work if you include --ignore-assertions flag to the hledger call?

Yes it does indeed. :) Your point 2. sounds good thanks. I will check in with hledger to see if this is expected from them.

The error should show the error message instead of list of numbers, I will debug this

Thanks! ๐Ÿ˜ Let me know if I can be of any more assistance for debugging.

@ananthakumaran I contacted the hledger devs and discovered that yes the assertions are supposed to be affected by periodic and auto transactions. See the warning at https://hledger.org/dev/hledger.html#assertions-and-auto-postings (which applies equally to periodic transactions as auto postings).

So for the purpose you mention here:

Paisa will export all the future transactions using the --forecast flag. Since I am only interested in the forecast transactions, I can ignore assertion failure.

Agreed, ignoring the assertion failure with --ignore-assertions is probably the best option. ๐Ÿ‘

cc @simonmichael

The fix for both issues is available on master. Thanks for the confirming with Hledger team.

Awesome, thanks! ๐Ÿ˜