hughsie / appstream-glib

This library provides objects and helper methods to help reading and writing AppStream metadata.
GNU Lesser General Public License v2.1
65 stars 103 forks source link

Error reporting of 'appstream-util validate' is too vague. #459

Open van-de-bugger opened 2 years ago

van-de-bugger commented 2 years ago
$ appstream-util --version
Version:    0.8.0

$ appstream-util validate ./io.sourceforge.kbd-tapper.metainfo.xml 
./io.sourceforge.kbd-tapper.metainfo.xml: FAILED:
• tag-invalid           : Expected children for tag
Validation of files failed

Ok, a tag in my metainfo file is invalid. But could appstream-validate give me a little hint which one? Either line number or at least invalid tag name would be appreciated.

The wrong metainfo file is attached. I have to replace .xml suffix with .txt in order to upload the file: github does not allow to upload xml files.

io.sourceforge.kbd-tapper.metainfo.txt

ximion commented 2 years ago

Using appstream-glib for this is no longer ideal, because it does not validate a lot of new concepts used in AppStream today. Validating with appstreamcli instead gives you:

~$ appstreamcli validate io.sourceforge.kbd-tapper.metainfo.xml
W: io.sourceforge.kbd-tapper:25: tag-empty requires
E: io.sourceforge.kbd-tapper:26: tag-invalid-text-content recommends
I: io.sourceforge.kbd-tapper:3: cid-contains-hyphen io.sourceforge.kbd-tapper

✘ Validation failed: errors: 1, warnings: 1, infos: 1

So, your requires tag in line 25 is empty, and your recommends tag in line 26 is invalid (see https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-relations for how this should look like).

van-de-bugger commented 2 years ago

Using appstream-glib for this is no longer ideal, because it does not validate a lot of new concepts used in AppStream today.

Thanks for replacement, but it does not solve the issue. Is appstream-util still maintained or completely abandoned? I see no reason why it doesn't print the warning like this one:

$ appstream-util validate ./io.sourceforge.kbd-tapper.metainfo.xml 
Warning: 'appstream-util validate' is outdated, use 'appstreamcli' instead.
...
ximion commented 2 years ago

Is appstream-util still maintained or completely abandoned?

I think @hughsie would call it "deep maintenance mode" ;-) - no major new features, but bugfixes are still applied and releases made. Appstream-glib is a separate project from AppStream itself, I'm not sure if it should print a warning like this... (would certainly not be a decision that I should make, as I am very biased and not the project's maintainer).

How does using the newer tool not solve the issue? As far as I can see, it tells you exactly what you want to know...

van-de-bugger commented 2 years ago

How does using the newer tool not solve the issue? As far as I can see, it tells you exactly what you want to know...

Your suggestion solves my problem. But it does not solve the problem the ticket is about: "Error reporting of 'appstream-util validate' is too vague." I understand appstream-util is in "deep maintenance mode", but I think it is good idea to inform users about it.