@@ -97,7 +97,7 @@ def __init__(self, *args):
97
97
)
98
98
from ops .framework import EventSource , Object
99
99
from ops .model import ModelError , Relation
100
- from pydantic import BaseModel , ConfigDict , Field
100
+ from pydantic import BaseModel , Field
101
101
102
102
# The unique Charmhub library identifier, never change it
103
103
LIBID = "12977e9aa0b34367903d8afeb8c3d85d"
@@ -107,7 +107,7 @@ def __init__(self, *args):
107
107
108
108
# Increment this PATCH version before using `charmcraft publish-lib` or reset
109
109
# to 0 if you are raising the major API version
110
- LIBPATCH = 8
110
+ LIBPATCH = 10
111
111
112
112
PYDEPS = ["pydantic" ]
113
113
@@ -338,7 +338,7 @@ class Config:
338
338
class ProtocolType (BaseModel ):
339
339
"""Protocol Type."""
340
340
341
- model_config = ConfigDict (
341
+ model_config = ConfigDict ( # type: ignore
342
342
# Allow serializing enum values.
343
343
use_enum_values = True
344
344
)
@@ -902,7 +902,16 @@ def _get_endpoint(
902
902
def get_endpoint (
903
903
self , protocol : ReceiverProtocol , relation : Optional [Relation ] = None
904
904
) -> Optional [str ]:
905
- """Receiver endpoint for the given protocol."""
905
+ """Receiver endpoint for the given protocol.
906
+
907
+ It could happen that this function gets called before the provider publishes the endpoints.
908
+ In such a scenario, if a non-leader unit calls this function, a permission denied exception will be raised due to
909
+ restricted access. To prevent this, this function needs to be guarded by the `is_ready` check.
910
+
911
+ Raises:
912
+ ProtocolNotRequestedError:
913
+ If the charm unit is the leader unit and attempts to obtain an endpoint for a protocol it did not request.
914
+ """
906
915
endpoint = self ._get_endpoint (relation or self ._relation , protocol = protocol )
907
916
if not endpoint :
908
917
requested_protocols = set ()
@@ -925,7 +934,7 @@ def get_endpoint(
925
934
def charm_tracing_config (
926
935
endpoint_requirer : TracingEndpointRequirer , cert_path : Optional [Union [Path , str ]]
927
936
) -> Tuple [Optional [str ], Optional [str ]]:
928
- """Utility function to determine the charm_tracing config you will likely want.
937
+ """Return the charm_tracing config you likely want.
929
938
930
939
If no endpoint is provided:
931
940
disable charm tracing.
0 commit comments