From 3e50838589cd03a57887127c92e46071dc2fc8c9 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 11:49:48 +0200 Subject: [PATCH] [PR #12063/3558e3c7 backport][stable-12] Fix flatpak id check (#12073) Fix flatpak id check (#12063) * Fix flatpak id check This PR fixes the flatpak ID check by allowing the last component of the ID to contain dashes. The regular expression will match the flatpak ID according to the flatpak specification. It matches all 4600+ IDs currently present in flathub. Fixes #12062 * Add changelog fragment * Update plugins/modules/flatpak.py * Update changelog fragment. --------- (cherry picked from commit 3558e3c74ace3f27172ee143535e8d1530597f6b) Co-authored-by: Gerben Welter Co-authored-by: Felix Fontein --- changelogs/fragments/12063-flatpak-id-check.yml | 2 ++ plugins/modules/flatpak.py | 11 ++--------- 2 files changed, 4 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/12063-flatpak-id-check.yml diff --git a/changelogs/fragments/12063-flatpak-id-check.yml b/changelogs/fragments/12063-flatpak-id-check.yml new file mode 100644 index 0000000000..cf79636e7e --- /dev/null +++ b/changelogs/fragments/12063-flatpak-id-check.yml @@ -0,0 +1,2 @@ +bugfixes: + - flatpak - fix reporting ``changed`` on already present flatpaks with a dash in the last part of the ID (https://github.com/ansible-collections/community.general/issues/12062, https://github.com/ansible-collections/community.general/pull/12063). diff --git a/plugins/modules/flatpak.py b/plugins/modules/flatpak.py index fe3659a006..ee2898b653 100644 --- a/plugins/modules/flatpak.py +++ b/plugins/modules/flatpak.py @@ -184,6 +184,7 @@ command: sample: "/usr/bin/flatpak install --user --nontinteractive flathub org.gnome.Calculator" """ +from re import match from urllib.parse import urlparse from ansible.module_utils.basic import AnsibleModule @@ -324,15 +325,7 @@ def _is_flatpak_id(part): # https://docs.flatpak.org/en/latest/conventions.html#application-ids # Flathub: # https://docs.flathub.org/docs/for-app-authors/requirements#application-id - if "." not in part: - return False - sections = part.split(".") - if len(sections) < 2: - return False - domain = sections[0] - if not domain.islower(): - return False - return all(section.isalnum() for section in sections[1:]) + return match(r"^[a-z]{2,}(\.\w+)+\.[\w-]+$", part) def _parse_flatpak_name(name):