Fix text output returned despite --output json in detached mode#1588
Open
Fix text output returned despite --output json in detached mode#1588
--output json in detached mode#1588Conversation
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix text output returned despite --output json
Fix text output returned despite Mar 5, 2026
--output json in detached mode
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes detached-mode startup output so devproxy --detach --output json returns JSON instead of always returning text, even before DI/logging is initialized.
Changes:
- Detects
--output jsonfrom raw args inStartDetachedProcessAsync. - Emits JSON on stdout for successful detached startup and JSON on stderr for error paths.
- Adds
IsJsonOutputRequestedhelper and usesProxyUtils.JsonSerializerOptionsfor serialization.
You can also share your feedback on Copilot code review. Take the survey.
Collaborator
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Contributor
Author
Applied in a65e725. JSON output now uses the same JSONL envelope format as
All output is single-line JSONL for consistent machine parsing across commands. |
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.
StartDetachedProcessAsyncinProgram.cswrites directly toConsole.Out/Console.Errorbefore the DI container and logging infrastructure are initialized, bypassingJsonConsoleFormatterentirely. The--output jsonflag was ignored.IsJsonOutputRequestedhelper that parses--output jsonfrom raw args (same pattern asConfigCommand.RunValidateStandaloneAsync)JsonConsoleFormatter:{"type":"result","data":{pid,apiUrl,logFile},"timestamp":"..."}{"type":"log","level":"error","message":"...","timestamp":"..."}With
--output json(success):{"type":"result","data":{"pid":6456,"apiUrl":"http://127.0.0.1:8897","logFile":"/Users/scope/.local/dev-proxy/logs/devproxy-6456-2026-03-05.log"},"timestamp":"2026-03-05T14:22:42.0000000Z"}With
--output json(error):{"type":"log","level":"error","message":"Dev Proxy is already running (PID: 6456). Use 'devproxy stop' to stop it first.","timestamp":"2026-03-05T14:22:42.0000000Z"}Without (unchanged):
Original prompt
--output json#1587🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.