saltstack / saltstack/salt

[BUG] Salt autocompletion fails with Fish shell

Open Beginner friendly
#64,240 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help-wanted needs-triage Packaging
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
Salt autocompletion fails with Fish shell

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM on our own VMware ESXi cluster
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior

On salt-master 3005.1, but also encountered on 3006, with the onedir install. Using fish shell, version 3.6.1.
Autocompletion while hitting tab after typing salt fails because completions functions are not in scope.

root@salt ~# salt __fish_salt_extract_function: command not found
in command substitution
__fish_salt_extract_minion: command not found
in command substitution
__fish_salt_extract_minion: command not found
fish:
not __fish_salt_extract_minion
    ^~~~~~~~~~~~~~~~~~~~~~~~~^
in command substitution

I narrowed the issue down to this line which seems to not work as expected:
https://github.com/saltstack/salt/blob/894c26780dafb2ebf50e4e90ec3863a921474aa2/pkg/common/fish-completions/salt.fish#L5

Sourcing salt_common.fish instead solves the problem but I'm not sure this is the correct solution as I'm not familiar with fish completions.

I reproduced the issue after cloning completion files from master in my user completion directory ~/.local/share/fish/vendor_completions.d and with the completion files provided by the latest ubuntu packages in /usr/share/fish/vendor_completions.d while running as root.

Expected behavior
Autocompletion should show available minions/functions for the current command.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3005.1

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.0
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: Not Installed
        Python: 3.9.16 (main, Jan  6 2023, 22:50:07)
  python-gnupg: 0.4.8
        PyYAML: 5.4.1
         PyZMQ: 23.2.0
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: ubuntu 22.04 jammy
        locale: ascii
       machine: x86_64
       release: 5.15.0-71-generic
        system: Linux
       version: Ubuntu 22.04 jammy

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with pkg/common/fish-completions/salt.fish at the reported line and compare how it loads salt_common.fish with the related completion files. Reproduce the failure in Fish 3.6.1 using the provided Salt completion files, then verify that tab completion lists available minions and functions without command-not-found errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
fish
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.