Salt file.append crashes due to python error

I am trying to use salt and file.append to configure a file and I’m running into a python error.

I am running file.append in a qube based on a debian-12-minimal template.

There seems to be open issues on github for this error, however from the comments it seems like there was an attempt at a backport fix for qubes for newer templates? Is debian-12-minimal excluded from this backport?
From what I can tell @unman 's configuration files use this template and use file.append which leads me to believe this should be possible?

One suggestion was to not use file.append, what is a suggested alternative to this?

Salt tracking issue: [BUG] file.py _get_flags issue · Issue #62676 · saltstack/salt · GitHub
Qubes tracking issue: Fedora 37 fails to update via salt. · Issue #7891 · QubesOS/qubes-issues · GitHub

salt code:

/home/user/foo:
  file.append:
    - text:
      - 'bar'

Error:

2024-07-05 18:44:11,894 output:           ID: /home/user/foo
2024-07-05 18:44:11,894 output:     Function: file.append
2024-07-05 18:44:11,894 output:       Result: False
2024-07-05 18:44:11,894 output:      Comment: An exception occurred in this state: Traceback (most recent call last):
2024-07-05 18:44:11,894 output:                 File "/var/tmp/.root_dd8a91_salt/pyall/salt/state.py", line 2171, in call
2024-07-05 18:44:11,894 output:                   ret = self.states[cdata["full"]](
2024-07-05 18:44:11,894 output:                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-05 18:44:11,894 output:                 File "/var/tmp/.root_dd8a91_salt/pyall/salt/loader.py", line 2105, in wrapper
2024-07-05 18:44:11,894 output:                   return f(*args, **kwargs)
2024-07-05 18:44:11,895 output:                          ^^^^^^^^^^^^^^^^^^
2024-07-05 18:44:11,895 output:                 File "/var/tmp/.root_dd8a91_salt/pyall/salt/states/file.py", line 6301, in append
2024-07-05 18:44:11,895 output:                   if __salt__["file.search"](
2024-07-05 18:44:11,895 output:                      ^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-05 18:44:11,895 output:                 File "/var/tmp/.root_dd8a91_salt/pyall/salt/modules/file.py", line 3154, in search
2024-07-05 18:44:11,895 output:                   return replace(
2024-07-05 18:44:11,895 output:                          ^^^^^^^^
2024-07-05 18:44:11,895 output:                 File "/var/tmp/.root_dd8a91_salt/pyall/salt/modules/file.py", line 2530, in replace
2024-07-05 18:44:11,895 output:                   flags_num = _get_flags(flags)
2024-07-05 18:44:11,895 output:                               ^^^^^^^^^^^^^^^^^
2024-07-05 18:44:11,895 output:                 File "/var/tmp/.root_dd8a91_salt/pyall/salt/modules/file.py", line 1653, in _get_flags
2024-07-05 18:44:11,895 output:                   _flag = getattr(re, str(flag).upper())
2024-07-05 18:44:11,895 output:                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-05 18:44:11,895 output:               AttributeError: module 're' has no attribute 'RE.MULTILINE'

What template are you using for your default-mgmt-dvm?
Update that template to fedora-40, and update the template.No issues
with debian-12-minimal.

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

Hmm, I am getting a similar issue with a clone of fedora-40-minimal when trying to use file.managed

2024-07-21 13:55:02,587 output:     _error:
2024-07-21 13:55:02,587 output:         Failed to return clean data
2024-07-21 13:55:02,587 output:     retcode:
2024-07-21 13:55:02,587 output:         1
2024-07-21 13:55:02,587 output:     stderr:
2024-07-21 13:55:02,588 output:         Traceback (most recent call last):
2024-07-21 13:55:02,588 output:           File "/var/tmp/.root_dd8a91_salt/salt-call", line 27, in <module>
2024-07-21 13:55:02,588 output:             salt_call()
2024-07-21 13:55:02,588 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/scripts.py", line 437, in salt_call
2024-07-21 13:55:02,588 output:             import salt.cli.call
2024-07-21 13:55:02,588 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/cli/call.py", line 6, in <module>
2024-07-21 13:55:02,588 output:             import salt.cli.caller
2024-07-21 13:55:02,588 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/cli/caller.py", line 14, in <module>
2024-07-21 13:55:02,588 output:             import salt.loader
2024-07-21 13:55:02,588 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/loader.py", line 23, in <module>
2024-07-21 13:55:02,588 output:             import salt.config
2024-07-21 13:55:02,588 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/config/__init__.py", line 17, in <module>
2024-07-21 13:55:02,588 output:             import salt.utils.data
2024-07-21 13:55:02,588 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/utils/data.py", line 14, in <module>
2024-07-21 13:55:02,588 output:             import salt.utils.dictupdate
2024-07-21 13:55:02,588 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/utils/dictupdate.py", line 20, in <module>
2024-07-21 13:55:02,588 output:             from salt.utils.decorators.jinja import jinja_filter
2024-07-21 13:55:02,589 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/utils/decorators/__init__.py", line 19, in <module>
2024-07-21 13:55:02,589 output:             import salt.utils.args
2024-07-21 13:55:02,589 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/utils/args.py", line 16, in <module>
2024-07-21 13:55:02,589 output:             import salt.utils.jid
2024-07-21 13:55:02,589 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/utils/jid.py", line 10, in <module>
2024-07-21 13:55:02,589 output:             import salt.utils.stringutils
2024-07-21 13:55:02,589 output:           File "/var/tmp/.root_dd8a91_salt/pyall/salt/utils/stringutils.py", line 22, in <module>
2024-07-21 13:55:02,589 output:             from salt.ext.six.moves import range  # pylint: disable=redefined-builtin
2024-07-21 13:55:02,589 output:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-21 13:55:02,589 output:         ModuleNotFoundError: No module named 'salt.ext.six.moves'
2024-07-21 13:55:02,589 output:     stdout:
2024-07-21 13:55:02,589 exit code: 20

Where is the error here? Is it a problem with the template? The template should be new.

What is the template for your default-mgmt-dvm?

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

Hmm, my global config GUI is not working for some reason. Is there a commandline way to see this?
This is the closest I found but doesn’t seem to be what you’re asking.

$qubes-prefs --get management_dispvm
default-mgmt-dvm

I am using a fedora-40 based default-mgmt-dvm without issue across all
templates. Make sure you have updated the base template, and try again.

qvm-prefs default-mgmt-dvm template

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

Ah, my management dvm was debian-11.
I’ve changed it to an up to date fedora and it seems to work.

If you feel like it I’d be super grateful if you’d explain the role of the management-disp-vm when using salt. I don’t understand the importance of this and I’d love to have greater clarity into how the system work.s

If you don’t feel like it or don’t have time then no problem. Thanks for the help!