Skip to content

Run osls without colors, even when FORCE_COLOR is set - #63

Merged
mnapoli merged 1 commit into
mainfrom
osls-without-colors
Sep 28, 2026
Merged

mnapoli merged 1 commit into
mainfrom
osls-without-colors

Conversation

@mnapoli

@mnapoli mnapoli commented Sep 28, 2026

Copy link
Copy Markdown
Member

When FORCE_COLOR is set in the environment (some CI systems set it, and so do coding agents), bref deploy of a serverless.yml application fails after the stack was deployed successfully:

✔ Service deployed to stack force-color-test-dev (64s)
…
× Impossible to parse the output of 'serverless info':
service: force-color-test
stage: dev
region: eu-west-3
stack: force-color-test-dev
…

The output looks parseable because the terminal renders the escape codes it contains: the bytes are \e[90mstack:\e[39m force-color-test-dev. osls inherits FORCE_COLOR and colors its output even though it isn't a terminal. retrieveOutputs() only strips non-ASCII characters, and escape codes are ASCII, so both the YAML parsing and the fallback regexes fail. The deployment is then marked as failed, without its outputs, and redeploying fails the same way.

Change

The CLI sets FORCE_COLOR=0 in the environment of the osls process. Its output is parsed (serverless info) and pushed as the deployment logs, so it should never have colors.

--no-color would not be enough: osls's color library gives FORCE_COLOR precedence over the flag. With FORCE_COLOR=3, osls --help prints 34 lines with escape codes, with or without --no-color, and none with FORCE_COLOR=0, for osls 3 and osls 4.

Tested

The same app deployed with FORCE_COLOR=3:

  • With the current release, the stack is deployed, then Impossible to parse the output of 'serverless info', exit code 1. The deployment is marked as failed, with the escape codes in its error message.
  • With this branch, it is deployed, exit code 0.

Unsetting FORCE_COLOR was the workaround until now.

When `FORCE_COLOR` is set (by some CI systems, or by coding agents), osls colors its output
even though it isn't a terminal. The output of `serverless info` then can't be parsed, so
`bref deploy` fails after the stack was deployed, and the deployment logs contain escape
codes. `--no-color` isn't enough: osls's color library gives `FORCE_COLOR` precedence.
The CLI now sets `FORCE_COLOR=0` for osls (3 and 4).

Claude-Session: https://claude.ai/code/session_01Awk33iZ9mDSg1xgSAPkgGK
@mnapoli
mnapoli merged commit 7a1eebf into main Sep 28, 2026
4 checks passed
@mnapoli
mnapoli deleted the osls-without-colors branch September 28, 2026 16:58
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.

1 participant