Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amount parsing crashes when the amount contains only an assertion #187

Closed
andreasrohnerdotnet opened this issue Oct 6, 2024 · 7 comments · Fixed by #188
Closed

Amount parsing crashes when the amount contains only an assertion #187

andreasrohnerdotnet opened this issue Oct 6, 2024 · 7 comments · Fixed by #188
Labels
bug Something isn't working

Comments

@andreasrohnerdotnet
Copy link

Reproduction steps
  1. Update NanoLedger from v0.4.6 to v0.6.0 via Obtainium (i.e. from GitHub)
  2. Start NanoLedger
  3. NanoLedger opens briefly without loading the ledger and and closes almost immediately
  4. Get Android error message "NanoLedger keeps stopping" (cf. screenshot)
    Screenshot_20241006-071155_Trebuchet
Expected behaviour

Keep working as reliably as the previous versions.

System information
  • Device: Xiaomi Poco X3 Pro
  • OS Version: LineageOS 20 (Android 13)
  • App Version: NanoLedger v0.6.0
Additional Context

My ledger is synced via Nextcloud.

Last, but not least, I want to take a moment to express my gratitude for your hard work and dedication to this amazing app. NanoLedger helps make plain text accounting a breeze.

@andreasrohnerdotnet andreasrohnerdotnet added the bug Something isn't working label Oct 6, 2024
@andreasrohnerdotnet
Copy link
Author

After clearing the NanoLedger's storage and cache NanoLedger v0.6.0 opens without issue.

However, the app crashes immediately after configuring the file in Settings » File by setting it to my ledger file (.txt) on my Nextcloud instance (content://org.nextcloud.documents/document/[string of numbers, letters and special charactes, e.g. % ]

@chvp
Copy link
Owner

chvp commented Oct 6, 2024

Hmm, that's not great. Since I had to parse the amounts for the edit functionality, I probably didn't cover an edge case there.

How familiar are you with android development? Any chance you could use adb logcat to get the logs for this crash?

And I know this is a lot to ask, but any chance you could share your journal file? If you don't want to share the whole file, you could try to minimise a reproduction sample by throwing away half of the transactions and seeing if the bug still occurs. If it does, keep going, if it doesn't, take the other half and keep going with those transactions.

@andreasrohnerdotnet
Copy link
Author

I am not familiar with Android development, unfortunately. However, I tried my best with adb logcat | grep be.chvp.nanoledger > ~/Downloads/crash_logs_nanoledger060.txt and my original hledger-file, a .txt-file with 731 transactions and a size of 153kB (cf. log-file attached
crash_logs_nanoledger060.txt.) Before running adb logcat I made sure that the my inputs are valid by running hledger in strict mode (i.e. hledger --strict).

As you suggested, I tried to reproduce the crashes with a reduced ledger file. Iterating over my hledger-file, it turned out that my opening balance statement was the culprit.

Setting opening balances according to https://hledger.org/1.40/hledger.html#setting-opening-balances does work in NanoLedger v0.6.0:

include ./accounts.txt
include ./commodities.txt
include ./prices.txt
include ./budget.txt

; Setting opening balances according to https://hledger.org/1.40/hledger.html#setting-opening-balances does work in NanoLedger v0.6.0
2016/1/1 opening balances
  assets:checking           $409.32 = $409.32
  assets:savings            $735.24 = $735.24
  assets:cash               $42  = $42
  equity:opening balances

Setting opening balances according to https://hledger.org/1.40/hledger.html#balance-assignments does not work in NanoLedger v0.6.0:

include ./accounts.txt
include ./commodities.txt
include ./prices.txt
include ./budget.txt
  
  ; Setting opening balances according to https://hledger.org/1.40/hledger.html#balance-assignments does not work in NanoLedger v0.6.0
2016/1/1 opening balances
  assets:checking            = $409.32
  assets:savings             = $735.24
  assets:cash                 = $42
  equity:opening balances

So the problem seems to be the parsing of Ledger-style balance assignments.

@chvp
Copy link
Owner

chvp commented Oct 6, 2024

Ah right, that's a thing as well. I'll try to work on a fix ASAP.

@chvp chvp changed the title NanoLedger v0.6.0 keeps stopping Amount parsing crashes when the amount contains only an assertion Oct 6, 2024
@chvp
Copy link
Owner

chvp commented Oct 6, 2024

Thanks for the help in diagnosing this issue! I worked on a fix in #188. Could you give the following APK a try? https://github.com/chvp/NanoLedger/actions/runs/11201905084/artifacts/2020684183

@andreasrohnerdotnet
Copy link
Author

I'm happy to report that your solution resolved this issue.

Thank you so much for your quick response and fix!

@chvp chvp closed this as completed in #188 Oct 6, 2024
chvp added a commit that referenced this issue Oct 6, 2024
@chvp
Copy link
Owner

chvp commented Oct 6, 2024

Great! I pushed the tag for a new release, it should be created automatically in a few minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants