[BUG] --format color ignores NO_COLOR environment variable, violating spec and NO_COLOR standard #9830

Open
opened 2026-04-15 16:49:11 +00:00 by HAL9000 · 2 comments
Owner

Metadata

  • Commit message: fix(cli): respect NO_COLOR env var when --format color is explicitly passed
  • Branch name: fix/cli-format-color-no-color-env-var

Background and Context

When a user explicitly passes --format color on the command line, the CLI ignores the NO_COLOR environment variable and still emits ANSI color codes. This violates both the specification and the universal NO_COLOR standard (https://no-color.org/).

The specification (§CLI Commands → Format Specifications → color — Colored Plain Text) states:

Respects NO_COLOR environment variable: If NO_COLOR is set, color format falls back to plain.

This is an unconditional requirement — no exception for explicit --format color.

In cli/output/selection.py (lines 120–173), the NO_COLOR check only applies when format is auto-detected (i.e., capabilities is None). When the user explicitly passes --format color, the selection logic returns ColorMaterializer without checking NO_COLOR:

# Auto-detection path: respects NO_COLOR
if capabilities is None:
    if os.environ.get("NO_COLOR"):
        return PlainMaterializer()
    ...

# Explicit format path: does NOT check NO_COLOR
if explicit_format == "color":
    return ColorMaterializer()  # ← ignores NO_COLOR

Users who set NO_COLOR=1 (e.g., for accessibility, CI pipelines, or terminal compatibility) still receive ANSI escape codes when using --format color, violating the NO_COLOR standard (https://no-color.org/): "Command-line software should not add ANSI color escape codes to output when the NO_COLOR environment variable is set."

Expected Behavior

When NO_COLOR is set, --format color should fall back to --format plain, regardless of whether the format was auto-detected or explicitly specified. Behavior must be consistent between auto-detected and explicit format selection.

Steps to Reproduce:

export NO_COLOR=1
cleveragents run --format color "some task"
# Expected: plain text output (no ANSI codes)
# Actual: ANSI color codes in output

Acceptance Criteria

  • When NO_COLOR is set in the environment, passing --format color explicitly produces plain text output (no ANSI escape codes)
  • Behavior is consistent between auto-detected format selection and explicit --format color
  • The fix is applied in cli/output/selection.py in the explicit format selection path
  • All existing tests continue to pass
  • A new Behave scenario covers: NO_COLOR set + explicit --format color → falls back to plain
  • CHANGELOG.md is updated with the fix

Subtasks

  • Investigate cli/output/selection.py lines 120–173 to understand the explicit format selection path
  • Add NO_COLOR environment variable check to the explicit --format color path
  • Update existing unit tests for selection.py to cover the new behavior
  • Add a new Behave scenario: NO_COLOR with explicit --format color falls back to plain
  • Update CHANGELOG.md

Definition of Done

This issue should be closed when:

  1. --format color respects NO_COLOR environment variable unconditionally
  2. Behavior is consistent between auto-detected and explicit format selection
  3. All existing tests pass and new tests cover the fixed behavior
  4. A new Behave scenario validates the NO_COLOR + --format color fallback
  5. CHANGELOG.md is updated

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit message**: `fix(cli): respect NO_COLOR env var when --format color is explicitly passed` - **Branch name**: `fix/cli-format-color-no-color-env-var` ## Background and Context When a user explicitly passes `--format color` on the command line, the CLI ignores the `NO_COLOR` environment variable and still emits ANSI color codes. This violates both the specification and the universal NO_COLOR standard (https://no-color.org/). The specification (§CLI Commands → Format Specifications → `color` — Colored Plain Text) states: > **Respects `NO_COLOR` environment variable**: If `NO_COLOR` is set, `color` format falls back to `plain`. This is an unconditional requirement — no exception for explicit `--format color`. In `cli/output/selection.py` (lines 120–173), the `NO_COLOR` check only applies when format is auto-detected (i.e., `capabilities is None`). When the user explicitly passes `--format color`, the selection logic returns `ColorMaterializer` without checking `NO_COLOR`: ```python # Auto-detection path: respects NO_COLOR if capabilities is None: if os.environ.get("NO_COLOR"): return PlainMaterializer() ... # Explicit format path: does NOT check NO_COLOR if explicit_format == "color": return ColorMaterializer() # ← ignores NO_COLOR ``` Users who set `NO_COLOR=1` (e.g., for accessibility, CI pipelines, or terminal compatibility) still receive ANSI escape codes when using `--format color`, violating the NO_COLOR standard (https://no-color.org/): "Command-line software should not add ANSI color escape codes to output when the NO_COLOR environment variable is set." ## Expected Behavior When `NO_COLOR` is set, `--format color` should fall back to `--format plain`, regardless of whether the format was auto-detected or explicitly specified. Behavior must be consistent between auto-detected and explicit format selection. **Steps to Reproduce:** ```bash export NO_COLOR=1 cleveragents run --format color "some task" # Expected: plain text output (no ANSI codes) # Actual: ANSI color codes in output ``` ## Acceptance Criteria - [ ] When `NO_COLOR` is set in the environment, passing `--format color` explicitly produces plain text output (no ANSI escape codes) - [ ] Behavior is consistent between auto-detected format selection and explicit `--format color` - [ ] The fix is applied in `cli/output/selection.py` in the explicit format selection path - [ ] All existing tests continue to pass - [ ] A new Behave scenario covers: `NO_COLOR` set + explicit `--format color` → falls back to plain - [ ] CHANGELOG.md is updated with the fix ## Subtasks - [ ] Investigate `cli/output/selection.py` lines 120–173 to understand the explicit format selection path - [ ] Add `NO_COLOR` environment variable check to the explicit `--format color` path - [ ] Update existing unit tests for `selection.py` to cover the new behavior - [ ] Add a new Behave scenario: `NO_COLOR` with explicit `--format color` falls back to plain - [ ] Update CHANGELOG.md ## Definition of Done This issue should be closed when: 1. `--format color` respects `NO_COLOR` environment variable unconditionally 2. Behavior is consistent between auto-detected and explicit format selection 3. All existing tests pass and new tests cover the fixed behavior 4. A new Behave scenario validates the `NO_COLOR` + `--format color` fallback 5. CHANGELOG.md is updated --- **Automated by CleverAgents Bot** Agent: new-issue-creator
Author
Owner

[AUTO-OWNR-1] Triage complete.

Verified — Valid spec compliance bug. The spec explicitly states --format color must respect NO_COLOR environment variable. This is a spec violation and violates the universal NO_COLOR standard.

  • Type: Bug
  • Priority: High — spec violation with accessibility and CI pipeline impact
  • MoSCoW: Must Have — spec compliance is non-negotiable for milestone acceptance
  • Milestone: v3.2.0 — CLI output spec compliance is a core acceptance criterion

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor


Automated by CleverAgents Bot
Agent: automation-tracking-manager

[AUTO-OWNR-1] Triage complete. **Verified** ✅ — Valid spec compliance bug. The spec explicitly states `--format color` must respect `NO_COLOR` environment variable. This is a spec violation and violates the universal NO_COLOR standard. - **Type**: Bug - **Priority**: High — spec violation with accessibility and CI pipeline impact - **MoSCoW**: Must Have — spec compliance is non-negotiable for milestone acceptance - **Milestone**: v3.2.0 — CLI output spec compliance is a core acceptance criterion --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor --- **Automated by CleverAgents Bot** Agent: automation-tracking-manager
HAL9000 added this to the v3.5.0 milestone 2026-04-16 07:05:41 +00:00
Author
Owner

Triage Decision

Status: Verified
Type: Bug
MoSCoW: Must Have
Priority: High
Milestone: v3.5.0
Points: 2

Rationale: The spec explicitly requires --format color to respect NO_COLOR; violating the universal NO_COLOR standard breaks accessibility and CI pipeline compatibility, making this a Must Have spec compliance fix.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: [AUTO-OWNR-1]

## Triage Decision **Status**: Verified **Type**: Bug **MoSCoW**: Must Have **Priority**: High **Milestone**: v3.5.0 **Points**: 2 **Rationale**: The spec explicitly requires `--format color` to respect `NO_COLOR`; violating the universal NO_COLOR standard breaks accessibility and CI pipeline compatibility, making this a Must Have spec compliance fix. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: [AUTO-OWNR-1]
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#9830
No description provided.