Repository navigation
fix: a collection of small model fixes - #2852
Open
tonyandrewmeyer wants to merge 8 commits into
Open
tonyandrewmeyer wants to merge 8 commits into
tonyandrewmeyer wants to merge 8 commits into
Conversation
* A charm subclassing a built-in status (to add a field, say) replaced the built-in in StatusBase's registry, so from_name() constructed the subclass when reading the status back from Juju and raised TypeError on every read. Built-in names now keep their built-in class. * RelationData held only a weakref proxy to its Relation. A Relation that the model does not cache (fetched by an ID that relation-ids does not list, as during relation-broken) was collected as soon as the caller dropped it, and then every access through .data raised ReferenceError. * Secret kept a reference to the caller's content dict rather than a copy. * Network parsing used strict ip_network(), which raises ValueError for a CIDR with host bits set, such as the interface's own address with the subnet's prefix length. * LazyNotice and LazyCheckInfo recursed forever in __getattr__ when copied, because copy looks the private attributes up before __init__ has run. * set_ports compared the protocol case-sensitively against opened-ports, so an upper-case protocol closed and reopened the port. * An unknown secret rotation policy from secret-info-get raised ValueError. * The get_content docstring claimed that set_content invalidates the cached content, which the code deliberately does not do. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ents Juju returns a pending secret-set value for peek or refresh in the same hook, and the tracked revision otherwise, so say that rather than "a later hook". Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The guard was in __init_subclass__, so the deprecated but public register() could still replace a built-in status. Moving the check to _register covers both paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… docstrings With several secrets rotating, the warning gave no way to tell which one has the policy that ops doesn't know. The get_secret docstring still said that set_content invalidates the cached content, which get_content's docstring no longer claims. The egress_subnets docstring now says that host bits are discarded, because strict=False does so silently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tonyandrewmeyer
marked this pull request as ready for review
November 8, 2026 23:04
dwilding
approved these changes
Nov 11, 2026
Co-authored-by: Dave Wilding <tech@dpw.me>
Co-authored-by: Dave Wilding <tech@dpw.me>
Co-authored-by: Dave Wilding <tech@dpw.me>
SecretInfo.from_dict silently dropped a rotation policy that ops doesn't know, while the backend's secret_info_get logs a warning naming the secret. Use the same warning, and only try to parse the policy when one is present, so that secrets without a policy don't log anything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A collection of small
model.pyfixes, none of which seemed worth a PR of its own:StatusBase._statuses, sofrom_name()constructed the subclass when reading the status back from Juju and raisedTypeErroron every read. Built-in names now keep their built-in class.RelationDataheld only aweakref.proxyto itsRelation(since the original 2019 code, with no recorded reason). ARelationthat the model doesn't cache (one fetched by an ID thatrelation-idsdoesn't list, as happens during relation-broken) was collected as soon as the caller dropped it, and then every access through.dataraisedReferenceError.Secretkept a reference to the caller's content dict rather than a copy.ip_network(), which raisesValueErrorfor a CIDR with host bits set, such as the interface's own address with the subnet's prefix length.LazyNoticeandLazyCheckInforecursed forever in__getattr__when copied, becausecopylooks the private attributes up before__init__has run.set_portscompared the protocol case-sensitively againstopened-ports, so an upper-case protocol closed and reopened the port.open_portandclose_portalready lowercase it, so this brings the three into line (the type hints forbid upper case anyway).secret-info-getraisedValueError.get_contentdocstring claimed thatset_contentinvalidates the cached content, which the code deliberately doesn't do (and the Scenario tests assert that it doesn't). Juju's hook context returns a pendingsecret-setvalue forpeekorrefreshin the same hook and the tracked revision otherwise, so the docstring now says that.