Fixed: "FutureWarning: invalid character '+' in URL-safe Base64 data will be discarded in future Python versions" When You Read MLflow Traces
On Python 3.15, a script that reads an MLflow trace back sometimes printed a FutureWarning about "URL-safe Base64 data", from a file in protobuf that my code never imports. It doesn't change any value; it's a library catching up with a Python change. Here's where it comes from, the report I filed, and how to hide exactly this warning meanwhile, with real output from MLflow 3.18.0 and protobuf 7.36.2.
What I Was Doing
I was reading a trace's token usage and cost in Python, right after tracing a Claude call: mlflow.get_trace(mlflow.get_last_active_trace_id(), flush=True), then trace.info.token_usage and trace.info.cost. MLflow 3.18.0 on Python 3.15.2.
What I Expected
The usage and cost lines, and nothing else.
What I Got
uv run --env-file .env token_cost.py
2026/11/30 17:34:35 INFO mlflow.tracking.fluent: Experiment with name 'token-cost' does not exist. Creating a new experiment.
/Users/you/source/token-cost/.venv/lib/python3.15/site-packages/google/protobuf/json_format.py:1065: FutureWarning: invalid character '+' in URL-safe Base64 data will be discarded in future Python versions
return base64.urlsafe_b64decode(padded_value)
Token usage: {'input_tokens': 29, 'output_tokens': 69, 'total_tokens': 98, 'cache_read_input_tokens': 0, 'cache_creation_input_tokens': 0, 'cache_creation_input_tokens_above_1hr': 0}
Cost (USD): {'input_cost': 0.000116, 'output_cost': 0.0013800000000000002, 'total_cost': 0.0014960000000000002}
2026/11/30 17:34:44 INFO mlflow.tracing.export.async_export_queue: Flushing the async trace logging queue before program exit. This may take a while...

The usage and cost were right. The warning came and went: another run of the same script printed nothing, and a smaller test that also reads traces back printed it twice in one run, once for '/' and once for '+'.
What I Checked
1. Who prints it. The file is google/protobuf/json_format.py, line 1065: protobuf's JSON parser, which MLflow uses when it reads a trace back. The line calls base64.urlsafe_b64decode.
2. What changed in Python 3.15. Python 3.15's urlsafe_b64decode warns when its input contains + or /, the two characters in which standard Base64 differs from the URL-safe alphabet, and says they "will be discarded in future Python versions". The change came with CPython pull request #141128, for issue gh-125346.
3. Why the input has those characters. Protobuf's JSON mapping writes bytes "using standard base64 encoding with paddings" and says "Either standard or URL-safe base64 encoding with/without paddings are accepted." Trace and span IDs are such bytes, so whether a + or / appears depends on the random ID. That's why the warning comes and goes.
4. The smallest case. Parsing protobuf's own standard Base64 output with protobuf alone, on Python 3.15 and then 3.14:
from google.protobuf import json_format, wrappers_pb2
# proto3 JSON writes bytes in standard base64, which uses '+' and '/'.
value = json_format.Parse('"+/8="', wrappers_pb2.BytesValue())
print(value.value)
print(json_format.MessageToJson(value))
uv run --no-project --python 3.15 --with protobuf==7.36.2 python repro.py
uv run --no-project --python 3.14 --with protobuf==7.36.2 python repro.py
Installed 1 package in 3ms
/Users/you/.cache/uv/archive-v0/q4T7pAS56GCBYD0I/lib/python3.15/site-packages/google/protobuf/json_format.py:1065: FutureWarning: invalid character '+' in URL-safe Base64 data will be discarded in future Python versions
return base64.urlsafe_b64decode(padded_value)
b'\xfb\xff'
"+/8="
Installed 1 package in 1ms
b'\xfb\xff'
"+/8="

Protobuf warns while reading back the very text it writes. The value decodes correctly on both versions.
5. Upstream. Protobuf 7.36.2 is the newest release, and its main branch still decodes this way. I found no existing report, so I filed protocolbuffers/protobuf#31887.
Why It Happens
Protobuf's JSON parser decodes every bytes value with Python's URL-safe Base64 decoder, which accepted the standard + and / silently until Python 3.15. Now it warns that a future version will drop them. Your code and your traces are fine; the warning is about a protobuf line that has to change before that future Python version arrives.
The Fix
There's nothing to repair in your project; the real fix is protobuf decoding both alphabets properly, tracked in protocolbuffers/protobuf#31887. Until it ships, you can hide this one warning with the PYTHONWARNINGS environment variable, set in the terminal before you run your script:
- macOS / Linux
- Windows (PowerShell)
export PYTHONWARNINGS="ignore:invalid character:FutureWarning:google.protobuf.json_format"
uv run --env-file .env token_cost.py
$env:PYTHONWARNINGS = "ignore:invalid character:FutureWarning:google.protobuf.json_format"
uv run --env-file .env token_cost.py
The filter has the form action:message:category:module. Python's warnings documentation defines each part:
ignore: don't print matching warnings.invalid character: inPYTHONWARNINGS, the message is "a literal string that the start of the warning message must match (case-insensitively)".FutureWarning: only this category.google.protobuf.json_format: the module is "a literal string that the fully qualified module name must be equal to (case-sensitively)", so the same warning from any other package still shows.
The variable lasts until you close the terminal. Keep Python 3.15; going back to 3.14 only hides the same protobuf line.
After the Fix
Because the warning depends on random IDs, the repro shows the effect reliably:
$ export PYTHONWARNINGS="ignore:invalid character:FutureWarning:google.protobuf.json_format"
$ uv run --no-project --python 3.15 --with protobuf==7.36.2 python repro.py
b'\xfb\xff'
"+/8="

The same command in PowerShell, with $env:PYTHONWARNINGS set, printed the same two lines without the warning.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Ignoring every FutureWarning | You miss warnings that do concern your code | Filter by message and module, as above |
| Downgrading Python to make it go away | You lose Python 3.15 for a warning that changes nothing today | Keep 3.15 and filter this one warning |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The warning still shows with the filter set | The filter was set in another terminal, or misspelled | Set it in the terminal you run from, and check the module name |
FAQ
Are my trace IDs wrong?
No. Python 3.15 still decodes + and / correctly; the warning is about a future version.
Will upgrading MLflow fix it?
The code that warns is in protobuf. A protobuf release that fixes #31887 will; MLflow uses whichever protobuf your project installs.
Conclusion
The FutureWarning came from protobuf decoding standard Base64 trace IDs with Python 3.15's URL-safe decoder, so it appeared only when an ID contained + or /. The values were right, the fix belongs in protobuf (#31887), and one PYTHONWARNINGS filter hides exactly this warning meanwhile.
Additional Resources
- protocolbuffers/protobuf#31887 — the report.
- The Warnings Filter — how
PYTHONWARNINGSfilters are written. - ProtoJSON format — how protobuf writes and reads bytes in JSON.
