Skip to content

Pebble service serialization and merging drop UID/GID zero #2846

Closed

Description

@ItsM0rty

pebble.Service.to_dict() drops user-id: 0 and group-id: 0. A pebble.Layer containing those fields loses them too.

from ops import pebble

layer = pebble.Layer({
    'services': {
        'api': {'override': 'replace', 'command': 'sleep infinity', 'user-id': 0, 'group-id': 0}
    }
})
print(layer.to_dict())
# {'services': {'api': {'override': 'replace', 'command': 'sleep infinity'}}}

Expected: both identity fields survive. A root identity is a valid value, rather than an omitted setting.

Service._merge() also skips zero, so an existing UID or GID of 1000 cannot be changed to 0 through that merge path. This can leave a service configured with the previous identity instead of the one the charm requested.

Reproduced on current main, Ops 3.10.0.dev0, with Python 3.12. Four local regression cases fail, covering serialization and merging for both fields. No Juju controller or Pebble daemon was used.

Activity

  1. added
    small item
    on Oct 25, 2026
  2. added a commit that references this issue on Nov 4, 2026
    41b19e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    small item

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions