Summary: | crash when importing csv with missing category | ||
---|---|---|---|
Product: | [Applications] kmymoney | Reporter: | Martin Tlustos <martin.tlustos> |
Component: | importer | Assignee: | KMyMoney Devel Mailing List <kmymoney-devel> |
Status: | RESOLVED FIXED | ||
Severity: | crash | ||
Priority: | NOR | ||
Version: | 5.1.1 | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/office/kmymoney/commit/12ef8de0febc644707791f0a5705e29abaa38da7 | Version Fixed In: | 5.1.2 |
Description
Martin Tlustos
2021-03-19 05:38:03 UTC
O.k., after searching for the cause of the problem I found that I had two colons the categories column in one of the entries and kmymoney obviously can't handle an empty category. My error, but kmymoney shouldn't crash, but give an appropriate warning. When importing a csv file, if a column is mapped to Category, and that column has a value of "::" in any row, an exception is thrown in kmymoney/mymoney/mymoneyfile.cpp (MyMoneyFile::addAccount line 938 in 5.1 git head, possibly different line in other branches). I assume this is trying to create an account for the category, since one doesn't already exist. While the exception is correct, I see two problems here. First, the exception should be caught, otherwise you get a crash. Second, a more helpful error message would indicate that the account in question is a Category, and not a regular Account, to give the user a better chance of finding and fixing the error in the input csv file. (Separate questions - should it be allowed to import a transaction without a category?) Can you provide a sample CSV file that shows the problem and explain the settings you have performed during the CSV import in detail? This way, we shall be able to duplicate the problem. Thanks in advance. 20201002,"Purchase",$190.00,"Memo" 20201003,"::",$190.00,"Memo" 20201004,"Purchase",$40.00,"Memo" The above three line csv file caused the crash for me. Columns mapped to date, category, amount, payee, and I imported using the "banking" profile. I had tried earlier to use a completely blank category, but the importer tried to exclude that line by adjusting the start and end lines to import, so I switched to the "::" as mentioned in Comment #1. I did not also try embedding the double colon within a longer string. I was using a newly created kmy file with just the checking account, and no categories initially created. The problem is using the colon without a following character. The colon is treated as a separator for account hierarchies at this point and gets removed during the process. This leaves an empty name which causes the crash. Git commit 12ef8de0febc644707791f0a5705e29abaa38da7 by Thomas Baumgart. Committed on 28/03/2021 at 06:14. Pushed by tbaumgart into branch '5.1'. Don't try to create an account without a name FIXED-IN: 5.1.2 M +3 -2 kmymoney/mymoney/mymoneyfile.cpp https://invent.kde.org/office/kmymoney/commit/12ef8de0febc644707791f0a5705e29abaa38da7 Git commit 0bee8c5200b1d4b19525796589dfc62abbe507a4 by Thomas Baumgart. Committed on 28/03/2021 at 06:23. Pushed by tbaumgart into branch 'master'. Don't try to create an account without a name (cherry picked from commit 12ef8de0febc644707791f0a5705e29abaa38da7) M +3 -2 kmymoney/mymoney/mymoneyfile.cpp https://invent.kde.org/office/kmymoney/commit/0bee8c5200b1d4b19525796589dfc62abbe507a4 |