Skip to content

fix(infra): a color terminal makes the fresh check differ from the plan #5352

Description

@dan-petty

Problem

devops infra apply stops at the fresh check when the person runs the apply in a color terminal and the plan came from a run with no terminal. The fresh check then shows more unchecked tasks than the plan, and the apply stops with "unchecked tasks: the plan has ..., the fresh check has ...".

Seen on 2026-11-13: an agent made a plan of ansible/playbooks/13_crash_capture.yaml for one host with no TERM in its environment. The plan shows 2 unchecked tasks. The owner ran the apply of that plan in the VS Code terminal (TERM=xterm-256color). The fresh check shows 7 unchecked tasks. The job events of both runs hold the same skip results. The only difference is that the stdout of each event in the fresh check starts with \x1b[0;36m and ends with \x1b[0m.

Cause

_is_check_mode_skip (src/devops_cli/infra/plan.py) reads the skip result after => in the event stdout as JSON. With the color codes, json.loads fails, and the function counts the skip as a check-mode skip (the safe side). Thus a skip by a false when counts as unchecked in a color terminal and not in a run without a terminal. ansible-runner gives ansible-playbook a pseudo-terminal, so Ansible colors its output when TERM names a color terminal. _PLAN_ENV does not set ANSIBLE_NOCOLOR.

Proposed fix

Set ANSIBLE_NOCOLOR=True in the environment of every plan, fresh check and run, so the event text is the same in each caller environment. Keep the safe side for a result that does not read.

Acceptance criteria

  • A test runs the plan parser on the job events of a skip by a false when with and without the color codes in stdout and gets the same plan. It fails on main (devops ci fail-to-pass).
  • A test finds ANSIBLE_NOCOLOR in the environment of the plan run and of the apply runs.
  • A plan made with no TERM and its apply in a terminal with TERM=xterm-256color pass the fresh check.

Workaround

Run the plan and the apply in the same kind of terminal, or run the apply with env -u TERM -u COLORTERM. ANSIBLE_NOCOLOR=1 in the caller environment does not help: the runner environment is an allowlist that passes TERM and COLORTERM and drops ANSIBLE_NOCOLOR, so the fix sets it in _PLAN_ENV.

Existing tool considered

Ansible has the setting ANSIBLE_NOCOLOR (nocolor in ansible.cfg). No new tool. Cost: about 40,000 tokens, 30 minutes elapsed.

Activity

  1. added
    source/agent
    type/bug
    scope/infra
    status/new
    value/medium
    effort/low
    priority/p2-medium
    on Nov 13, 2026
  2. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor
  3. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    The workaround in the body does not work. A second apply with ANSIBLE_NOCOLOR=1 in the caller environment stopped the same way. The runner environment is an allowlist (src/devops_cli/core/process.py, near line 97): it passes TERM and COLORTERM from the caller and drops ANSIBLE_NOCOLOR. The command artifact of the apply holds TERM and COLORTERM; the plan's has neither. So the fix must put ANSIBLE_NOCOLOR in _PLAN_ENV, which the run adds after the allowlist. The workaround until then: run the apply with env -u TERM -u COLORTERM, which gives the runner the same environment as the plan.

  4. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 13, 2026
  5. removed
    status/in-review
    owner/agent
    on Nov 13, 2026
  6. added a commit that references this issue on Nov 13, 2026
  7. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor
  8. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-13 12:38 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/infrasource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions