Skip to content

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
gyanranjanpanda:fix/issue-1980-run-command-formats
Open

Fix #1980: Centralize output format definitions and sync run command with print-safe formats#2061
gyanranjanpanda wants to merge 1 commit intoaboutcode-org:mainfrom
gyanranjanpanda:fix/issue-1980-run-command-formats

Conversation

@gyanranjanpanda
Copy link

@gyanranjanpanda gyanranjanpanda commented Feb 21, 2026

Fixes #1980 by removing duplicated output format definitions and introducing a single source of truth for supported formats.

The run command 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 the output command. Since run internally uses stdout streaming (--print), it must restrict formats to those compatible with streaming (excluding csv and xlsx).

This PR centralizes format definitions and ensures both commands remain synchronized while preserving the safety constraints of the run command.


Changes

  • Added canonical constants in scanpipe/pipes/output.py:

    • SUPPORTED_FORMATS — all formats supported by the output command

    • PRINT_SUPPORTED_FORMATS — subset compatible with stdout streaming

  • Updated scanpipe/management/commands/output.py to import SUPPORTED_FORMATS.

  • Updated scanpipe/management/commands/run.py to use PRINT_SUPPORTED_FORMATS instead of a hardcoded list.

  • Added regression tests to ensure:

    • Format lists stay synchronized

    • PRINT_SUPPORTED_FORMATS remains a strict subset of SUPPORTED_FORMATS

    • Incompatible formats are rejected early by argparse


Behavior

Command | Before | After

Behavior

## Behavior
Command Before After
run --format spdx ✅ Worked ✅ Works
run --format cyclonedx ✅ Worked ✅ Works
run --format ort-package-list ❌ Could fall out of sync ✅ Works
run --format csv ⚠️ Could crash (not print-safe) ❌ Rejected early
run --format xlsx ⚠️ Could crash (binary) ❌ Rejected early
output --format csv ✅ Worked ✅ Works
output --format xlsx ✅ Worked ✅ Works

Result

  • run automatically 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.

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>
@gyanranjanpanda gyanranjanpanda force-pushed the fix/issue-1980-run-command-formats branch from ad243e0 to 73972a2 Compare February 21, 2026 13:49
@gyanranjanpanda
Copy link
Author

Hi,@aryansinha could u review this

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.

run command does not support all scancode.io outputs

1 participant