`ops.pebble` silently drops layer fields it doesn't know about
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with Layer, Service, Check, and LogTarget in ops/pebble.py, then inspect add_layer() and get_plan() to trace how dictionaries are converted and returned. Compare the two proposed approaches and check how layer merging currently works. Done means unknown fields survive dictionary round trips, or are reported when dropped, with consistent behavior for dict and YAML inputs.
Written by the indexing model from the issue text.
Description
ops.pebble only keeps the layer fields it knows about. Layer keeps summary, description, services, checks and log-targets, and Service (and Check and LogTarget) read a fixed list of keys. add_layer turns a dict into Layer(layer).to_yaml(), so anything else a charm passes is silently dropped before Pebble sees it, and get_plan() drops it on the way back too. A YAML string is passed through as it is, so the same layer behaves differently depending on its type.
The current example is a service's workload field (plan.go) and the workloads section. Neither Juju 3.6 nor Juju main registers the workloads section extension (only the standalone pebble run does), so this doesn't break anything under Juju today, hence rainy day. But whenever Pebble adds a field, a charm that passes it in a dict loses it without any warning until ops catches up.
We should do one of these:
- Keep the keys we don't know about and pass them back out in
to_dict(), so that a dict round-trips. This is the most forward-compatible, but merging a layer with an unknown field would need some thought. - Warn (or raise) when a key is dropped, so that it's at least visible.
I lean towards the first, with merging treating unknown fields as "replace".
- Dominant language
- Python
- Stars
- 267
- Forks
- 156
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 43
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from canonical/operator
-
tests
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 3 days
-
rainy day small item
Difficulty 2/5 1-3 hours Newbie friendliness 71/100
Maintainers usually reply within 3 days
-
Cleaning up inconsistencies in the Manage relations how-to pagePossibly taken @tromai claimed this 1 day ago. Opendocs roadmap
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
canonical/operator#2688 · 3 comments · 1 assignee ·
Maintainers usually reply within 3 days
-
docs rainy day tests
Difficulty 3/5 1-2 days Newbie friendliness 56/100
canonical/operator#2952 · 1 reaction ·
Maintainers usually reply within 3 days
-
docs rainy day
Difficulty 3/5 1-2 days Newbie friendliness 43/100
Maintainers usually reply within 3 days
All issues in canonical/operator
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
abetlen/llama-cpp-python#2424 ·
Maintainers usually reply within 1 day
-
Bug IronPython Python 3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
pyrevitlabs/pyRevit#4184 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 74/100
jqueryscript/awesome-claude-code#1009 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
[Plugin] 群聊记忆 · 人格养成Open
Difficulty 1/5 1-3 hours Newbie friendliness 74/100