Closed ghost closed 3 years ago
Last backtrace from original code I could get: ` Thread 1 "brewtarget" received signal SIGSEGV, Segmentation fault. 0x00005555556b0032 in Ingredient::isValid (this=0x0) at /home/random/sources/brewtarget/src/ingredient.cpp:281 281 return _valid; (gdb) bt
at /usr/include/qt5/QtCore/qobjectdefs_impl.h:152
f=(void (MainWindow::*)(MainWindow * const)) 0x55555580b7de <MainWindow::importFiles()>, o=0x555556188b40, arg=0x7fffffffd8d0)
at /usr/include/qt5/QtCore/qobjectdefs_impl.h:185
this_=0x555556c35140, r=0x555556188b40, a=0x7fffffffd8d0, ret=0x0) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:418
from /usr/lib/libQt5Widgets.so.5
This is a very interesting bug. I have a fix for it which I will post soon.
So, the fun bit is fixed in https://github.com/Brewtarget/brewtarget/pull/501.
@r4nd0m6uy There are still problems loading in the files you link to, but I don't yet know enough about what expected behaviour is. Specifically, once the above fix is applied, importing the file 'recipes_Guix-5.0.0.xml' blows up because the code cannot handle a MashStep that doesn't have a name. (If you manually edit the XML to insert random text into
Hoy @matty0ung,
Thanks for your quick reply and quick fix! Indeed, I would not have found it myself in less than one day :stuck_out_tongue: ...
Singletone ... mmm hhh ... For the last issue, I don't mind editing my XML and can live with it, although I fix is very welcome!
Thanks and keep the great work!
Didn't test myself though, I guess you did and you can close the issue if you feel confident :+1:
No worries. :-)
For the rest of the issue, my instinct is that, when reading files, the software should try to "make sense" as best it can of the input - so, in this case, generate some arbitrary name to replace the 'missing' one and carry on processing the rest of the file. (Conversely, for writing files, we should obviously aim to generate exemplary BeerXML.) If others agree then I would be happy to have a go at making the file reading really robust in this way, but it's probably a non-trivial change, so I think I ought to wait for @mikfire to comment/approve my current 'big' pull request (https://github.com/Brewtarget/brewtarget/pull/499) before I dive into it.
I just want to confirm that I have tested the patch and after fixing my recipe as suggested, it works! https://gitlab.com/morandg/GuixBeers/-/commit/d5f4220e7dab4c45931f4432c063fc14bbdfea03
I would like to apologize for the aggressive post, I was very frustrated that I couldn't tweak my recipe, now I'm very happy and will order my ingredients!
Thanks again @matty0ung , you are awesome! Long live to open source and nice communities!
You're welcome. Always glad to help a fellow brewer! :+1:
If you ever wanted to know what I hate about BeerXML, it is this. Nobody generates BeerXML to spec, and the spec is written in a way that we cannot use validators on the input.
Technically, this bug is in the generating software. The BeerXML spec says NAME is a required attribute in a MASH_STEP. Yes, our code should be more defensive, but I think we should at least be able to assume required fields are present.
@mikfire I hear what you're saying. At the same time, it seems on this occasion that we should say nice things about the generating software because line two of the file being imported says 'BeerXML generated by brewtarget'. :smiley:
can we consider this Issue Resolved? or is further development on the import necessary?
Yes, I think given that, with a bit of manual editing, OP was able to get brewing after the fix, then we can close this. I will raise a separate enhancement issue to make the XML input more robust.
Thank you guys! If I dare giving my opinion to reply @mikfire comment:
If you ever wanted to know what I hate about BeerXML, it is this. Nobody generates BeerXML to spec, and the spec is written in a way that we cannot use validators on the input.
Technically, this bug is in the generating software. The BeerXML spec says NAME is a required attribute in a MASH_STEP. Yes, our code should be more defensive, but I think we should at least be able to assume required fields are present.
I don't think BeerXML neither XML is bad, it's just that XML is very often missused or not well understood. It seems that no one validate its XML against the (BeerXML) schema that results in the mess it is today... Or should we send a feature request for a better BeerXML XSD?
One thing I've done in the past with importing XML, which could help us a bit, is to parse the file twice. The first time you validate and can let the user know if there are any heinous errors that you can't deal with. The second time, if the first time was OK, you actually import the data. That way you don't, say, get half-way through injecting a new recipe in your database before hitting an unrecoverable problem.
Checking again the specification from http://beerxml.com/
It seems that it was not done by XML experts. I don't find any DTD neither an XSD to validate against but a text document that vaguely describes the formate, now all this mess makes sense. Althought @matty0ung does all the best he can, he will probably never produce something viable. Instead of fixing weird issues in brewtarget, the problem should be fixed at the root, this means trying to collaborate with original authors and submit an XSD. Or did I miss something?!
Out of topics but some thoughts on my side ... :thinking:
I tried fixing this problem a long time ago by creating an XSD from that doc. If I understood everything correctly, XSD can work with tags in random order or with optional tags. It cannot work with both. BeerXML has both and so XSD cannot be made to work.
My intense dislike for BeerXML isn't because it is XML. BeerXML is bad XML. I've asked a few of the other projects informally, and there is no interest in trying to work on beerXML v2.0, which would be the only way to fix the issue.
I would prefer BeerXML to die in fire, to be replaced by BeerJSON. Assuming that project actually wrote the schema files.
I am having a play around with the XSDs reverse-engineered from the BrewXML spec by Jon Lochner (@brewpoo), but it's good to know the limitations that you encountered @mikfire. I do have an idea about how we might nonetheless end up with something useful, but it needs some more investigation. I think it will be something fun to keep me occupied over the Christmas break. Will post results in https://github.com/Brewtarget/brewtarget/issues/504 as and when I have any conclusions.
Shall we make a separate issue (if there is not one already) for supporting https://github.com/beerjson/beerjson format?
I would say that beerJSON deserves a separate issue/feature-request on its own.
Hallo Brewtarget developpers!
I have been trying importing my old beer recipes but it always crashes. Fixing one issue, another one shows up and I'm wondering if someone have tried this feature recently that seems totally broken. The following beer recipes always fail to import, despite they were exported with brewtarget: https://gitlab.com/morandg/GuixBeers/-/tree/master/recipes
I don't know if I'm doing something wrong. I wish I could fix and PR myself but I'm getting lost in the issues from issues nightmare, any pointer is strongly appreciated.
Best regards,
Guy