Skip to content

fix: support Pydantic MISSING sentinel in ops.Relation.save#2306

Merged
dimaqq merged 8 commits intocanonical:mainfrom
dimaqq:fix-relation-save-missing-field
Feb 25, 2026
Merged

fix: support Pydantic MISSING sentinel in ops.Relation.save#2306
dimaqq merged 8 commits intocanonical:mainfrom
dimaqq:fix-relation-save-missing-field

Conversation

@dimaqq
Copy link
Copy Markdown
Contributor

@dimaqq dimaqq commented Feb 4, 2026

Support Pydantic's experimental MISSING sentinel field types and values.

ops.Relation.load() does the right thing already.
ops.Relation.save() needs a small fix to erase missing fields

Check list:

Fixes #2299

Copy link
Copy Markdown
Contributor

@james-garner-canonical james-garner-canonical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core code change looks good to me, as does the to-do list.

@dimaqq dimaqq changed the title fix: support Pydantic MISSING sentinal in ops.Relation.save fix: support Pydantic MISSING sentinel in ops.Relation.save Feb 4, 2026
@dimaqq dimaqq marked this pull request as ready for review February 16, 2026 01:53
Copy link
Copy Markdown
Contributor

@james-garner-canonical james-garner-canonical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks good based on our team discussion.

The addition of a class using this sentinel to the tests is great, ensuring that we don't crash on MISSING anymore. I think it would be a good idea to add a test that explicitly asserts that MISSING doesn't get serialized as well.

Are you still planning to add some real Juju tests, per the checklist in the PR description? I'm not sure if they're necessary, but I'm definitely not opposed to us adding more integration tests.

Copy link
Copy Markdown
Collaborator

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remain unconvinced that there's a need to support this use-case, and also that "MISSING" should mean "REMOVE", but the PR does implement the team decision.

I do think we should explicitly document the behaviour in a comment - maybe also in the reference doc as well (it feels like that should be expected if we want charms to rely on this behaviour).

Copy link
Copy Markdown
Contributor

@james-garner-canonical james-garner-canonical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the new behaviour and with the test coverage.

Copy link
Copy Markdown
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me, thanks.

@dimaqq dimaqq merged commit 38eab2b into canonical:main Feb 25, 2026
59 checks passed
@dimaqq dimaqq deleted the fix-relation-save-missing-field branch February 25, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support pydantic.experimental.missing_sentinel.MISSING in ops.Relation.save

4 participants