Skip to content

[Bug]: KeyError: "getpwnam(): name not found: 'sudo_username'" #69600

Description

@gyro666

What happened?

There is an error started showing since upgraded from 3006.25 to 3006.26 (latest)
I have several orchestrations that we run after sudo -i. It worked fine up to 3006.25 version.

salt-run state.orchestrate orch.os_updates pillar='{"env": "mgmt"}' used to run fine on 3006.25. Now it throws the following error:

pp-salt-01.domain_dom_master:
    Data failed to compile:
----------
    Rendering SLS 'base:orch.os_updates' failed: Problem running salt function in Jinja template: Failed to run 'cache.grains' as user 'sudo_myusername': KeyError: "getpwnam(): name not found: 'sudo_myusername'"; line 105

---
[...]

# Full scope with blackout exclusion
{% set env_scope = env_compound ~ ' ' ~ blackout %}

# Resolve single (non-cluster) minions, excluding blacklisted
{% set single_minions = salt.saltutil.runner('cache.grains', tgt=env_scope ~ ' and not G@cl_node:*', tgt_type='compound') %}    <======================

I am running it as sudo user. The whole story behind the orchestration is not important. The bit that changed is that now saltutil.runner triggers getpwname for SUDO_USER and of course there is no such user so it errors out.

Type of salt install

Official deb

Major version

3006.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

debian-12

salt --versions-report output

Salt Version:
          Salt: 3006.26

Python Version:
        Python: 3.10.20 (main, Jun 11 2026, 02:19:33) [GCC 11.2.0]

Dependency Versions:
          cffi: 2.0.0
      cherrypy: 18.10.0
  cryptography: 47.0.0
      dateutil: 2.9.0.post0
     docker-py: Not Installed
         gitdb: 4.0.12
     gitpython: 3.1.50
        Jinja2: 3.1.6
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.1.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.0
     pycparser: 3.00
      pycrypto: Not Installed
  pycryptodome: 3.23.0
        pygit2: Not Installed
  python-gnupg: 0.5.6
        PyYAML: 6.0.3
         PyZMQ: 27.1.0
        relenv: 0.22.14
         smmap: 5.0.2
       timelib: 0.3.0
       Tornado: 6.5.5
           ZMQ: 4.3.5

System Versions:
          dist: debian 12.14 bookworm
        locale: utf-8
       machine: x86_64
       release: 6.1.0-49-amd64
        system: Linux
       version: Debian GNU/Linux 12.14 bookworm

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbroken, incorrect, or confusing behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions