As API keys for Gemini for example go in the URL when reqwest encounters an HTTP error, its Display impl includes the full URL and then probably a From<reqwest::Error> for LLMError is happening somewhere that converts it to an LLMError::HttpError(String) resulting in the key being embedded.
Whilst it's not the worse that could happen there are many ways in which logs get leaked. Many companies, including ours use 3rd party logging solutions and as a result will be shipping api keys to them unknowingly.
As we caught this early we scrub them from the log with simple replace before it leaves the process but the string matching on key=...is just a disaster waiting to happen in a future upgrade.
Are you open to adding more granular structured reqwest errors maybe by expanding LLMError::HttpError from a string to LLMError::HttpError(LLMHttpError)?
I'm happy to do this as a contribution as well but it would probably touch a few areas of the code hence thought i'd ask before sending a PR as to if and what form you want a solution to take
As API keys for Gemini for example go in the URL when reqwest encounters an HTTP error, its Display impl includes the full URL and then probably a
From<reqwest::Error> for LLMErroris happening somewhere that converts it to anLLMError::HttpError(String)resulting in the key being embedded.Whilst it's not the worse that could happen there are many ways in which logs get leaked. Many companies, including ours use 3rd party logging solutions and as a result will be shipping api keys to them unknowingly.
As we caught this early we scrub them from the log with simple replace before it leaves the process but the string matching on
key=...is just a disaster waiting to happen in a future upgrade.Are you open to adding more granular structured reqwest errors maybe by expanding
LLMError::HttpErrorfrom a string toLLMError::HttpError(LLMHttpError)?I'm happy to do this as a contribution as well but it would probably touch a few areas of the code hence thought i'd ask before sending a PR as to if and what form you want a solution to take