Skip to content

[Bug]: msgpack deserialization error during grains refresh #68678

@sheagcraig

Description

@sheagcraig

What happened?

A small number of Mac devices in our environment logged the following traceback many, many times per day.

-0700 2024-06-19T08:36:19,377 [salt.minion      :1180][CRITICAL][716] Unexpected error while connecting to salt
Traceback (most recent call last):
  File "/opt/salt/lib/python3.10/site-packages/salt/payload.py", line 100, in loads
    ret = salt.utils.msgpack.unpackb(msg, **loads_kwargs)
  File "/opt/salt/lib/python3.10/site-packages/salt/utils/msgpack.py", line 157, in unpackb
    return msgpack.unpackb(packed, **_sanitize_msgpack_unpack_kwargs(kwargs))
  File "msgpack/_unpacker.pyx", line 202, in msgpack._cmsgpack.unpackb
msgpack.exceptions.ExtraData: unpack(b) received extra data.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/salt/lib/python3.10/site-packages/salt/minion.py", line 1151, in _connect_minion
    minion.tune_in(start=False)
  ...
  File "/opt/salt/lib/python3.10/site-packages/salt/loader/__init__.py", line 1063, in _load_cached_grains
    salt.payload.load(fp_), preserve_tuples=True
  File "/opt/salt/lib/python3.10/site-packages/salt/payload.py", line 221, in load
    return loads(data, encoding="utf-8")
  File "/opt/salt/lib/python3.10/site-packages/salt/payload.py", line 120, in loads
    raise SaltDeserializationError(exc_msg) from exc
salt.exceptions.SaltDeserializationError: Could not deserialize msgpack message. See log for more info.

This was caused by a grains cache which failed msgpack deserialization and, since that exception is not handled, becomes a CRITICAL failure. No clue how the grains cache is getting messed up, and we have eliminated this issue by just disabling the grains cache, but I have a PR incoming.

Type of salt install

Official pkg

Major version

3007.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)

macos-15

salt --versions-report output

Salt Version:
          Salt: 3007.11
 
Python Version:
        Python: 3.10.19 (main, Jan  7 2026, 23:46:58) [Clang 17.0.0 (clang-1700.0.13.5)]
 
Dependency Versions:
          cffi: 2.0.0
      cherrypy: 18.8.0
  cryptography: 42.0.5
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.6
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.7
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.5.2
        PyYAML: 6.0.1
         PyZMQ: 25.1.2
        relenv: 0.22.2
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.5.4
           ZMQ: 4.3.4
 
Salt Package Information:
  Package Type: onedir
 
System Versions:
          dist: darwin 25.2.0 
        locale: utf-8
       machine: arm64
       release: 25.2.0
        system: Darwin
       version: 26.2 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbroken, incorrect, or confusing behaviorneeds-triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions