Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Juju 4.0 no longer includes private-address in the default relation databags. The Scenario testing framework was incorrectly including it for all Juju versions.

Changes

  • Runtime processing: Modified Runtime.exec() to remove private-address from all relation databags when simulating Juju 4.0+, applied after state deep-copy where both state and Juju version are available
  • Relation type coverage: Handles Relation, SubordinateRelation, and PeerRelation databags (local unit, remote units, and peers)
  • Tests: Added parameterized tests verifying presence in Juju 3.x and absence in Juju 4.0+

Example

from scenario import Context, State
from scenario.state import Relation

# Juju 3.6: private-address is present
ctx = Context(MyCharm, juju_version='3.6.4')
rel = Relation(endpoint='foo', interface='foo')
ctx.run(ctx.on.relation_changed(rel), State(relations={rel}))
# relation.data[unit] contains: egress-subnets, ingress-address, private-address

# Juju 4.0: private-address is absent
ctx = Context(MyCharm, juju_version='4.0.0')
rel = Relation(endpoint='foo', interface='foo')
ctx.run(ctx.on.relation_changed(rel), State(relations={rel}))
# relation.data[unit] contains: egress-subnets, ingress-address

The solution avoids modifying Relation constructors (where Juju version is unavailable) by processing databags post-deepcopy in the runtime where both state and version are accessible.

Original prompt

This section details on the original issue you should resolve

<issue_title>Don't include private-address in the default Scenario database when mocking Juju 4</issue_title>
<issue_description>The private-address key is not included in the default relation settings (databag) as of Juju 4.0, so we should not include it in the mock one either, if the mock Juju version is 4.0+.

The default contents are currently set when a Relation (etc) object is created. We don't have access to the relevant Context object at that time (which is where the Juju version is), so we'll have to figure out what the best way of handling this is.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 16, 2026 07:00
Co-authored-by: dimaqq <662249+dimaqq@users.noreply.github.com>
Co-authored-by: dimaqq <662249+dimaqq@users.noreply.github.com>
Co-authored-by: dimaqq <662249+dimaqq@users.noreply.github.com>
Co-authored-by: dimaqq <662249+dimaqq@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix default Scenario database by excluding private-address fix: remove private-address from relation databags for Juju 4.0+ Jan 16, 2026
Copilot AI requested a review from dimaqq January 16, 2026 07:10
@dimaqq
Copy link
Contributor

dimaqq commented Jan 16, 2026

@tonyandrewmeyer wdyt about this approach?

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.

Don't include private-address in the default Scenario database when mocking Juju 4

2 participants