ADK Python issue 7311: spans exported OAuth secrets that repr hid. On 2.14.1 the legacy schema or span content capture still exported them before the 13 November fix.
What 2.14.1 actually exports
The issue reproduced the leak on ADK 2.10.0 with no environment variables set. Between 2.10 and 2.14.1 something else changed: release 2.13.0 (23 October) made OpenTelemetry GenAI semantic conventions v2 the default telemetry schema. I ran the issue's own reproduction script against google-adk 2.14.1 in a virtual environment resolved with uv's --exclude-newer 2026-11-14T23:59:59Z, so every dependency was one available on 14 November (pydantic 2.14.3, opentelemetry-sdk 1.45.2, google-genai 2.34.0, fastapi 0.163.0), on Windows 11 with CPython 3.13.5. The script records spans with an in-memory exporter and reports any canary secret found in a span attribute.
| Environment | Secrets in span attributes |
|---|---|
| No variables set (schema v2 default) | none |
ADK_TELEMETRY_SCHEMA_VERSION_OPT_IN=1 (legacy schema) | all three, in gcp.vertex.agent.tool_call_args |
Legacy schema and ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS=false | none |
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY | all three, in gen_ai.tool.call.arguments |
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_AND_EVENT | all three, in gen_ai.tool.call.arguments |
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=EVENT_ONLY or true | none in span attributes |
So on 2.14.1 the default no longer puts tool arguments into span attributes, but the two common ways of asking for content in spans, pinning the legacy schema that earlier releases used by default or opting in to span content capture, still export the secrets. In these runs the tool response did not carry the secrets on 2.14.1, unlike the issue's 2.10.0 output. The script checks span attributes only; I did not inspect log events, so EVENT_ONLY and true are "not in span attributes", not "safe".
I then installed ADK from the fix commit b6952874 itself, in a second environment resolved the same way, and ran the same seven configurations: no secret reached a span attribute in any of them, including the legacy schema and both span capture modes.
If you ran an ADK Python release before 2.13.0 with default tracing and the OAuth credential flow, the issue's reproduction says your exported spans contained these values. If you run 2.13 or later with span content capture or the legacy schema, my runs say they still did on 2.14.1, and stopped at the fix commit.
The general bug: hiding is not masking
The same gap exists outside ADK and outside pydantic. In standard Python, dataclasses.field(repr=False) hides a value from repr(), and dataclasses.asdict() returns it. Any "turn the object into a dict, then JSON" helper inherits that. The companion example builds a tool-call object with an OAuth credential whose secrets are runtime-generated canary strings, exports it through a naive serializer and through a masking one into an in-memory exporter, and reports what reached the attributes:
repr()shows none of the canaries;- the naive serializer exports all three from the credential, plus an access token that arrived as a plain dictionary in a tool response;
- the masking serializer exports none, and still keeps an ordinary key such as
token_count.
The masking serializer does what the ADK fix does, in miniature. It masks by type while it can still see the live objects, before dumping flattens them into dictionaries, and it masks by shape for credential payloads that arrive as plain dictionaries:
CREDENTIAL_TYPES = (OAuthCredential,)
SECRET_KEYS = {'access_token', 'refresh_token', 'client_secret', 'id_token', 'password', 'api_key'}
def _mask(value):
if isinstance(value, CREDENTIAL_TYPES):
return '<redacted>' # by declared type
if dataclasses.is_dataclass(value) and not isinstance(value, type):
return {f.name: _mask(getattr(value, f.name)) for f in dataclasses.fields(value)}
if isinstance(value, dict):
return {k: ('<redacted>' if k in SECRET_KEYS else _mask(v)) for k, v in value.items()}
if isinstance(value, (list, tuple)):
return [_mask(v) for v in value]
return valueThe ADK change walks the live value alongside its dump for the same reason: once a model is dumped to a dict, its type is gone and only key names remain. Its tests also cover aliases, root models, computed fields and reference cycles, which is where a short version like this one would leak.
Why repr=False was never a control
repr=False answers a display question: what appears when an object is printed in a log line or a debugger. It does not change what the object holds or what any serializer emits. Pydantic has a type for the other question: a field declared as SecretStr prints as SecretStr('********'), and model_dump(mode="json") and model_dump_json() both emit '********'; only an explicit get_secret_value() returns the value. Checked locally with pydantic 2.13.3, a model with one SecretStr field and one Field(repr=False) string dumps the first as asterisks and the second in the clear. Typing secrets as secret types moves masking into the model instead of every serializer. It does not remove the need for the serializer fix, because credentials also arrive as plain dictionaries, which have no type to consult.
What to do if you run ADK Python agents with OAuth tools
- Find out what your spans contain. Check whether you pin
ADK_TELEMETRY_SCHEMA_VERSION_OPT_IN=1or setOTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENTto a span mode, and which ADK version you ran when. - Search stored traces. Query your tracing backend for the attributes
gcp.vertex.agent.tool_call_args,gcp.vertex.agent.tool_responseandgen_ai.tool.call.argumentscontainingaccess_token,refresh_tokenorclient_secret. The companion includes a small scanner for exported span JSON that walks nested JSON strings and reports secret-named keys holding values. - Revoke and reissue anything found. Refresh tokens and client secrets are long-lived; deleting the spans does not undo a copy already in a backend, an export or a support case.
- Turn off content in spans until you upgrade. Set
ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS=falseif you use the legacy schema, and do not use a span mode of the OTel capture variable. In my runs that removed the secrets from span attributes on 2.14.1. - Upgrade to a release that contains b6952874, and keep a canary test in CI: run one tool call with a fake credential through your real exporter configuration and fail if the canary appears in any attribute.
Treat traces as a data store
Traces are often configured by platform teams for latency and errors and then quietly start carrying content when someone turns on capture for debugging. A trace backend then becomes a store of tool arguments and responses with broad read access and long retention. Give it the controls you give any store of customer data: an explicit decision about which content is captured, masking at the source, not in the backend, retention limits, and access reviews. Masking in the backend is too late; the secret has already left the process.
Failure modes
- A second serializer path. The fix notes that masking applies only to values passed through
safe_json_serialize; the experimental semantic-convention code uses its own serializer. Test the exporter configuration you run, not a function. - Secrets under unexpected names, such as a vendor's
x-api-keyheader inside a tool argument. Extend the shape list from your own tools. - Masking that also removes keys you need, such as
token_count. Match whole key names, and test that ordinary fields survive. - Canary tests that use realistic-looking secrets and trip a secret scanner in CI. Build canaries at run time from an obviously fake prefix.
Limits
I ran the issue's script on 2.14.1 and on the fix commit, each with a dependency set dated 14 November; I did not run ADK 2.10.0, and I did not inspect log events or the experimental serializer separately. The companion uses dataclasses to show the mechanism, not ADK.