Repository navigation
Description
Title: Custom command steps: atmos describe ... --format json | jq fails from a terminal since 1.234.0 (ATMOS_FORCE_COLOR forwarded to children)
Describe the Bug
Since v1.234.0, a custom command step that pipes nested atmos describe ... --format json into jq fails whenever the parent atmos runs in a terminal:
jq: parse error: Invalid numeric literal at line 1, column 2
The example components command in the custom commands docs (website/docs/cli/configuration/commands/command/commands.mdx) fails this way.
Custom command steps now receive ATMOS_FORCE_COLOR=true in their environment (added in #3454, commit 146b733, via terminal.ChildColorEnv from OutputModeWriter.ChildEnvironment). The nested atmos describe treats that as "force colour even into pipes" (pkg/utils/highlight_utils.go, where ForceColor bypasses the stdout TTY check), so the JSON written to the pipe is syntax-highlighted with ANSI escapes.
atmos list ... -f json is unaffected; only the highlighted describe output breaks. Running without a TTY (CI, | cat) is also unaffected, because nothing is forwarded then.
Expected Behavior
Machine-readable output (--format json/yaml) piped from a nested atmos inside a custom command step stays plain, as in v1.230.1, while colour still flows through to output that ends up on the terminal.
Steps to Reproduce
atmos.yaml:
base_path: "."
components:
terraform:
base_path: components/terraform
stacks:
base_path: stacks
included_paths: ["*.yaml"]
name_template: "{{ .vars.stage }}"
commands:
- name: components
description: List components (example from the custom commands docs)
steps:
- atmos describe stacks --format json | jq ".[].components.terraform" | jq -s add | jq -r "keys[]"stacks/dev.yaml:
vars:
stage: dev
components:
terraform:
demo:
vars: {}components/terraform/demo/main.tf:
variable "stage" {}Run atmos components from an interactive terminal. On Linux, script -qec "atmos components" /dev/null provides a PTY non-interactively.
Results (linux/amd64, jq 1.7):
| Parent atmos | No TTY | TTY |
|---|---|---|
| 1.230.1 | demo |
demo |
| 1.234.1 | demo |
jq: parse error: Invalid numeric literal at line 1, column 2 |
Inside the step, env | grep FORCE_COLOR prints nothing on 1.230.1 and ATMOS_FORCE_COLOR=true on 1.234.1. The result is the same when the nested atmos binary is held at 1.234.1 and only the parent changes.
Workarounds Tried
unset ATMOS_FORCE_COLORat the start of the step or script works, and restores the 1.230.1 environment.--no-colororNO_COLOR=1on the nested call works.--file out.jsonworks, because file output is never highlighted.--force-color=falseon the nested call does not help; the output is still highlighted.CLICOLOR=0alongside the forwarded variable does not help.
Suggested Fix
One of:
- Forward a "colour permitted" hint instead of
ATMOS_FORCE_COLOR, so children still detect pipes on their own stdout. - Don't syntax-highlight structured
--format json/yamldata output when stdout is not a TTY, even when colour is forced.
Environment
- atmos 1.234.1;
pkg/terminal/child_color.goandpkg/utils/highlight_utils.goare unchanged onmainas of 6ec7424. - Linux amd64
Activity