Fix #1980: Centralize output format definitions and sync run command with print-safe formats#2061
Open
gyanranjanpanda wants to merge 1 commit intoaboutcode-org:mainfrom
Conversation
Centralize output formats in pipes/output.py and ensure only stdout streaming compatible formats are enabled for the run command. Signed-off-by: Gyan Ranjan Panda <gyanranjanpanda@gmail.com>
ad243e0 to
73972a2
Compare
Author
|
Hi,@aryansinha could u review this |
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.
Fixes #1980 by removing duplicated output format definitions and introducing a single source of truth for supported formats.
The
runcommand previously relied on a hardcoded list of formats, which could fall out of sync when new formats (e.g.ort-package-list) were added to theoutputcommand. Sinceruninternally uses stdout streaming (--print), it must restrict formats to those compatible with streaming (excludingcsvandxlsx).This PR centralizes format definitions and ensures both commands remain synchronized while preserving the safety constraints of the
runcommand.Changes
Added canonical constants in
scanpipe/pipes/output.py:SUPPORTED_FORMATS— all formats supported by theoutputcommandPRINT_SUPPORTED_FORMATS— subset compatible with stdout streamingUpdated
scanpipe/management/commands/output.pyto importSUPPORTED_FORMATS.Updated
scanpipe/management/commands/run.pyto usePRINT_SUPPORTED_FORMATSinstead of a hardcoded list.Added regression tests to ensure:
Format lists stay synchronized
PRINT_SUPPORTED_FORMATSremains a strict subset ofSUPPORTED_FORMATSIncompatible formats are rejected early by argparse
Behavior
Behavior
run --format spdxrun --format cyclonedxrun --format ort-package-listrun --format csvrun --format xlsxoutput --format csvoutput --format xlsxResult
runautomatically supports newly added print-compatible formats.Incompatible formats are safely rejected before execution.
Eliminates duplicated configuration and prevents future drift between commands.
No behavioral regressions.