Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: clarify --trace flag behavior with --output flag #1060

Merged

Conversation

thevilledev
Copy link
Contributor

@thevilledev thevilledev commented Feb 9, 2025

Improve documentation to make it clear that when both --trace and --output flags are specified, the output format takes priority over tracing. This helps users understand that they cannot combine tracing with custom output formats like JSON or table.

Relates to #1031

@thevilledev thevilledev force-pushed the fix/trace-with-output branch 2 times, most recently from 22b9b7e to 0dea545 Compare February 10, 2025 15:59
@jalseth
Copy link
Member

jalseth commented Feb 11, 2025

I am concerned that this will break users who accidentally have --trace enabled with an output other than Standard. I think the --output flag is more important to prioritize.

Is it possible to enable tracing without changing the output style?

@thevilledev
Copy link
Contributor Author

thevilledev commented Feb 11, 2025

At this time tracing is only implemented in the standard output format. Since choosing the output format is a single pass it's one or the other. If we prioritise output over trace then the only option would be to ignore it, which is what conftest is already doing. Maybe give a warning, although if the warning is written to stdout it will break piping use cases like conftest test <args> | jq .

A bit of a larger refactoring would be to separate trace output handling from the output format and write it to a separate stream. Quite common approach for debug/trace outputs. Something like this:

  • Default behavior (no -o flag):
    • Standard output format → stdout
    • Trace info (if enabled) → stderr
  • Custom output (with -o flag):
    • Chosen format (table/json/etc) → stdout
    • Trace info in standard format (if enabled) → stderr

So with conftest test --trace -o json you would see both trace and the json output but on different streams, enabling piping as before and likely less of a breaking change for many.

@jalseth
Copy link
Member

jalseth commented Feb 19, 2025

That makes sense, thanks. For now, I'd like to leave it as-is with preference for the output flag, and we can add to the description of the trace flag to clarify that it only has an effect for the standard output.

Improve documentation to make it clear that when both --trace and --output
flags are specified, the output format takes priority over tracing. This
helps users understand that they cannot combine tracing with custom output
formats like JSON or table.

Signed-off-by: Ville Vesilehto <[email protected]>
@thevilledev thevilledev force-pushed the fix/trace-with-output branch from 0dea545 to 2ec2265 Compare February 21, 2025 18:48
@thevilledev thevilledev changed the title feat(output): force standard format when tracing is enabled docs: clarify --trace flag behavior with --output flag Feb 21, 2025
Copy link
Member

@jalseth jalseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Thanks!

@jalseth jalseth merged commit 5ae180f into open-policy-agent:master Mar 1, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants