Skip empty console messages in JSON output mode#7701
Draft
Conversation
…on errors Agent-Logs-Url: https://github.com/Azure/azure-dev/sessions/f5638e5b-3026-4fcf-80e7-24c5b72f97e2 Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix leading newlines in azd auth token json output on failure
Skip empty console messages in JSON output mode
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
azd auth token -ojsonemits a spurious{"type":"consoleMessage","data":{"message":"\n"}}line before the error JSON when authentication fails. This is caused byconsole.Message(ctx, "")calls used as visual separators (blank lines) in text mode — in JSON mode,EventForMessage("")appends a trailing\nto the empty string, producing a meaningless event.Changes
cli/azd/pkg/input/console.go— Early-return inMessage()when the message is empty and format is JSON. Empty messages are visual separators with no semantic value in structured output.cli/azd/pkg/input/console_test.go— AddedTestAskerConsole_Message_EmptySkippedInJsoncovering both the skip and the pass-through for non-empty messages.Before:
After: