When azd auth token fails, it writes JSON to stderr:
{"type":"consoleMessage","timestamp":"...","data":{"message":"\nERROR: fetching token: ..."}}
Today AzureDeveloperCliCredential includes this raw JSON verbatim in error messages, producing noisy output like:
AzureDeveloperCliCredential authentication failed: {"type":"consoleMessage","timestamp":"...","data":{"message":"\nERROR: fetching token: ..."}}
We should instead parse this JSON's .data.message field to produce cleaner errors like:
AzureDeveloperCliCredential authentication failed: ERROR: fetching token: ...
Note .data.message may contain leading/trailing whitespace that should be trimmed.
This also lets us remove special-case error handling (e.g., substituting another message when azd's contains "azd auth login") because the parsed messages from azd are already user-friendly.
When JSON parsing fails or .data.message isn't set or has an empty value, include the raw text as before.
When
azd auth tokenfails, it writes JSON to stderr:{"type":"consoleMessage","timestamp":"...","data":{"message":"\nERROR: fetching token: ..."}}Today AzureDeveloperCliCredential includes this raw JSON verbatim in error messages, producing noisy output like:
We should instead parse this JSON's
.data.messagefield to produce cleaner errors like:This also lets us remove special-case error handling (e.g., substituting another message when azd's contains "azd auth login") because the parsed messages from azd are already user-friendly.
When JSON parsing fails or
.data.messageisn't set or has an empty value, include the raw text as before.