Skip to content

fix: allow desktop files without an Exec key - #6298

Open
WaiHlyanMinThein17 wants to merge 1 commit into
canonical:mainfrom
WaiHlyanMinThein17:5799-allow-desktop-file-without-exec
Open

fix: allow desktop files without an Exec key#6298
WaiHlyanMinThein17 wants to merge 1 commit into
canonical:mainfrom
WaiHlyanMinThein17:5799-allow-desktop-file-without-exec

Conversation

@WaiHlyanMinThein17

Copy link
Copy Markdown

Fixes #5799

Desktop entries without an Exec key are valid when the application is D-Bus- or systemd-activated (often with NoDisplay=true), so the shell can still match an icon and metadata to a GUI that isn't launched directly. desktop-file-validate accepts such files, but snapcraft rejected them with missing 'Exec' key.

This makes the Exec reformatting conditional on the key being present instead of raising when it's absent, so the file is written through unchanged. The separate "missing Desktop Entry section" guard is untouched. The existing test_missing_exec_entry is converted from asserting rejection to asserting the file is written faithfully without an Exec line.

The issue suggested delegating validation to desktop-file-validate rather than encoding key requirements in snapcraft. I went with this minimal in-tree fix to keep it focused and avoid a new external dependency, but I'm happy to take the delegation approach if the team prefers it.

ruff, ty, and make test-fast (3628 passed, 0 failed) all pass. make lint fails locally only in its docs build (TypeError: issubclass() arg 1 must be a class, Sphinx on Python 3.14); I confirmed the same failure on a clean upstream/main, so it's pre-existing and unrelated to this change.


  • I've followed the contribution guidelines.
  • I've signed the CLA.
  • I've successfully run make lint && make test. (Code linters and make test-fast pass; make lint docs build fails identically on clean main.)
  • I've added or updated any relevant documentation. (n/a)
  • In documents I changed, I added a meta description if one was missing. (n/a)
  • I've updated the relevant release notes. (n/a)

Desktop entries that are D-Bus- or systemd-activated (commonly with
NoDisplay=true) are valid without an Exec key, per the Desktop Entry
specification and desktop-file-validate. Snapcraft was rejecting them
with "missing 'Exec' key". Only reformat the Exec line when present.

Fixes canonical#5799
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.

Valid desktop file without Exec key are rejected

1 participant