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

Handle missing Flatpaks gracefully #135

Merged
merged 2 commits into from
Nov 30, 2023
Merged

Conversation

wjt
Copy link
Member

@wjt wjt commented Nov 30, 2023

Previously, if a listed Flatpak app or runtime is not present in that
remote, remote.match() would return None, but the calling code would
assume it is not None. This leads to a failure like this:

+ 20:16:29 INFO eibflatpak: Looking for app ref "com.orama_interactive.Pixelorama" match in flathub
+ 20:16:29 INFO eibflatpak: Removing repo option core.xa.languages
+ 20:16:29 INFO eibflatpak: Removing repo option core.xa.extra-languages
+ 20:16:29 INFO eibflatpak: Removing repo option core.xa.masked
Traceback (most recent call last):
  File "/tmp/image-build-IZAJlTeyep/eos-image-builder/hooks/content/50-flatpak", line 61, in <module>
    manager.pull()
  File "/tmp/image-build-IZAJlTeyep/eos-image-builder/lib/eibflatpak.py", line 837, in pull
    txn = self._new_transaction()
  File "/tmp/image-build-IZAJlTeyep/eos-image-builder/lib/eibflatpak.py", line 808, in _new_transaction
    self._add_installs(txn)
  File "/tmp/image-build-IZAJlTeyep/eos-image-builder/lib/eibflatpak.py", line 799, in _add_installs
    logger.info('Adding app %s from %s', ref.ref, remote.name)
AttributeError: 'NoneType' object has no attribute 'ref'

Handle this gracefully, collecting all errors in case more than one
Flatpak is missing, then fail at the end.

https://phabricator.endlessm.com/T34603

wjt added 2 commits November 30, 2023 20:56
Yes, this is harder to read, but I'm about to add error handling that
would otherwise be duplicated.

https://phabricator.endlessm.com/T34603
Previously, if a listed Flatpak app or runtime is not present in that
remote, remote.match() would return None, but the calling code would
assume it is not None. This leads to a failure like this:

    + 20:16:29 INFO eibflatpak: Looking for app ref "com.orama_interactive.Pixelorama" match in flathub
    + 20:16:29 INFO eibflatpak: Removing repo option core.xa.languages
    + 20:16:29 INFO eibflatpak: Removing repo option core.xa.extra-languages
    + 20:16:29 INFO eibflatpak: Removing repo option core.xa.masked
    Traceback (most recent call last):
      File "/tmp/image-build-IZAJlTeyep/eos-image-builder/hooks/content/50-flatpak", line 61, in <module>
        manager.pull()
      File "/tmp/image-build-IZAJlTeyep/eos-image-builder/lib/eibflatpak.py", line 837, in pull
        txn = self._new_transaction()
      File "/tmp/image-build-IZAJlTeyep/eos-image-builder/lib/eibflatpak.py", line 808, in _new_transaction
        self._add_installs(txn)
      File "/tmp/image-build-IZAJlTeyep/eos-image-builder/lib/eibflatpak.py", line 799, in _add_installs
        logger.info('Adding app %s from %s', ref.ref, remote.name)
    AttributeError: 'NoneType' object has no attribute 'ref'

Handle this gracefully, collecting all errors in case more than one
Flatpak is missing, then fail at the end.

https://phabricator.endlessm.com/T34603
@wjt wjt requested a review from dbnicholson November 30, 2023 21:01
@wjt
Copy link
Member Author

wjt commented Nov 30, 2023

Draft because totally untested.

Copy link
Member

@dbnicholson dbnicholson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I'd be comfortable merging this as is if you don't have time to test.

@wjt wjt marked this pull request as ready for review November 30, 2023 21:41
@wjt
Copy link
Member Author

wjt commented Nov 30, 2023

Tested this with 1 found and 2 not-found refs, it looks good:

+ 21:40:44 INFO eibflatpak: Looking for app ref "org.freedesktop.Bustle" match in flathub
+ 21:40:44 INFO eibflatpak: Adding app app/org.freedesktop.Bustle/x86_64/stable from flathub
(process:49709): flatpak-DEBUG: 21:40:44.363: Fetching summary index file for remote ‘flathub’
(process:49709): flatpak-DEBUG: 21:40:44.363: Loading https://dl.flathub.org/repo/summary.idx using curl
(process:49709): flatpak-DEBUG: 21:40:44.428: Received 10001 bytes
(process:49709): flatpak-DEBUG: 21:40:44.452: Loaded indexed summary file 0085996624446d6a2648cfe204cdca177355784c27bf916681c001b4f3d33e2d from cache for remote ‘flathub’
(process:49709): flatpak-DEBUG: 21:40:44.452: Transaction: install flathub:app/org.freedesktop.Bustle/x86_64/stable[*]
+ 21:40:44 INFO eibflatpak: Looking for app ref "org.freedesktop.Hustle" match in flathub
+ 21:40:44 ERROR eibflatpak: app org.freedesktop.Hustle not found from flathub
+ 21:40:44 INFO eibflatpak: Looking for app ref "org.freedesktop.Rustle" match in flathub
+ 21:40:44 ERROR eibflatpak: app org.freedesktop.Rustle not found from flathub
+ 21:40:44 INFO eibflatpak: Removing repo option core.xa.languages
+ 21:40:44 INFO eibflatpak: Removing repo option core.xa.extra-languages
+ 21:40:44 INFO eibflatpak: Removing repo option core.xa.masked
Traceback (most recent call last):
  File "/sysroot/home/wjt/src/endlessm/eos-image-builder/hooks/content/50-flatpak", line 61, in <module>
    manager.pull()
  File "/sysroot/home/wjt/src/endlessm/eos-image-builder/lib/eibflatpak.py", line 854, in pull
    txn = self._new_transaction()
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/sysroot/home/wjt/src/endlessm/eos-image-builder/lib/eibflatpak.py", line 825, in _new_transaction
    self._add_installs(txn)
  File "/sysroot/home/wjt/src/endlessm/eos-image-builder/lib/eibflatpak.py", line 818, in _add_installs
    raise FlatpakError(
eibflatpak.FlatpakError: Could not find listed flatpaks: org.freedesktop.Hustle, org.freedesktop.Rustle

@wjt wjt merged commit e1648e2 into master Nov 30, 2023
2 checks passed
@wjt wjt deleted the T34603-handle-missing-flatpaks branch November 30, 2023 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants