Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2.1] Need to guard against a relation broken event #45

Closed
sed-i opened this issue Jun 14, 2023 · 0 comments · Fixed by #47
Closed

[v2.1] Need to guard against a relation broken event #45

sed-i opened this issue Jun 14, 2023 · 0 comments · Fixed by #47

Comments

@sed-i
Copy link
Contributor

sed-i commented Jun 14, 2023

When removing an app that was related to self-signed-certificates, the following error is raised:

  File "/var/lib/juju/agents/unit-am-0/charm/lib/charms/tls_certificates_interface/v2/tls_certificates.py", line 1366, in _on_relation_broken
    if not relation.data[relation.app].get("certificates"):  # type: ignore[index]
  File "/var/lib/juju/agents/unit-am-0/charm/venv/ops/model.py", line 1346, in __getitem__
    raise KeyError(
KeyError: 'Cannot index relation data with "None". Are you trying to access remote app data during a relation-broken event? This is not allowed.'

Seems like there's a missing guard:

if not relation.app or not relation.app.name:
    # Handle edge case where remote app name can be missing, e.g.,
    # relation_broken events.

Related: canonical/operator#888

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 a pull request may close this issue.

1 participant