fix(otel): normalise list guardrail_mode to tuple in _emit_once to avoid TypeError

This commit is contained in:
devteamaegis 2026-05-22 01:52:31 -04:00
parent d04373f4ce
commit 3a1bb525a4

View file

@ -955,7 +955,14 @@ class OpenTelemetry(OTELGenAISemconvMixin, CustomLogger):
spans_logged = {}
_otel_internal["spans_logged"] = spans_logged
dedupe_key = (self.__class__.__name__, id(self), *scope)
# Normalise scope parts so they are always hashable. `guardrail_mode`
# can be a list (e.g. ["pre_call", "post_call"]) and a tuple containing
# a list is itself unhashable, causing a TypeError when used as a dict key.
normalized_scope = tuple(
tuple(part) if isinstance(part, list) else part
for part in scope
)
dedupe_key = (self.__class__.__name__, id(self), *normalized_scope)
if spans_logged.get(dedupe_key) is True:
return False