Run osls without colors, even when FORCE_COLOR is set - #63
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
FORCE_COLORis set in the environment (some CI systems set it, and so do coding agents),bref deployof aserverless.ymlapplication fails after the stack was deployed successfully: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 inheritsFORCE_COLORand 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=0in 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-colorwould not be enough: osls's color library givesFORCE_COLORprecedence over the flag. WithFORCE_COLOR=3,osls --helpprints 34 lines with escape codes, with or without--no-color, and none withFORCE_COLOR=0, for osls 3 and osls 4.Tested
The same app deployed with
FORCE_COLOR=3: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.deployed, exit code 0.Unsetting
FORCE_COLORwas the workaround until now.