flathub-infra / flatpak-builder-lint

A linter for flatpak-builder manifests
MIT License
48 stars 125 forks source link

Build metadata parser errors on mulitple groups with same names #316

Closed bbhtt closed 6 months ago

bbhtt commented 6 months ago

Say a metadata file with:

[Extension org.foo.Bar.Locale]
directory=share/runtime/langpack
autodelete=true
locale-subset=true

[Extension org.foo.Bar.Locale]
directory=share/runtime/locale
autodelete=true
locale-subset=true

One is autogenerated by flatpak-builder, one is explicitly added via manifest like this:

add-extensions:
 org.foo.Bar.Locale:
  directory: share/runtime/langpack
  autodelete: true
  locale-subset: true

Obviously this is wrong, but flatpak/flatpak-builder doesn't consider this as an error.

But the linter cannot parse this:

Traceback (most recent call last):
  File "/app/bin/flatpak-builder-lint", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/app/lib/python3.11/site-packages/flatpak_builder_lint/cli.py", line 169, in main
    if results := run_checks(args.type, path, args.exceptions, args.appid):
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/flatpak_builder_lint/cli.py", line 70, in run_checks
    check_method(check_method_arg)
  File "/app/lib/python3.11/site-packages/flatpak_builder_lint/checks/appid.py", line 41, in check_build
    metadata = builddir.get_metadata(path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/flatpak_builder_lint/builddir.py", line 18, in get_metadata
    metadata = parse_metadata(f.read())
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/flatpak_builder_lint/builddir.py", line 26, in parse_metadata
    parser.read_string(ini)
  File "/usr/lib/python3.11/configparser.py", line 739, in read_string
    self.read_file(sfile, source)
  File "/usr/lib/python3.11/configparser.py", line 734, in read_file
    self._read(f, source)
  File "/usr/lib/python3.11/configparser.py", line 1086, in _read
    raise DuplicateSectionError(sectname, fpname,
configparser.DuplicateSectionError: While reading from '<string>' [line 30]: section 'Extension org.foo.Bar.Locale' already exists

This can be override by strict=false but might not be the best idea.