Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TF-11813] do not colorize runHeader when returned as err #34473

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

laurenolivia
Copy link
Contributor

@laurenolivia laurenolivia commented Jan 3, 2024

Fixes #

We should not call colorize on strings that are returned as error messages.

Target Release

1.5.x

Draft CHANGELOG entry

NEW FEATURES | UPGRADE NOTES | ENHANCEMENTS | BUG FIXES | EXPERIMENTS

  • Fix terminal error by removing colorized text

Before

Screenshot 2024-01-16 at 3 17 57 PM

After

Screenshot 2024-01-22 at 5 23 15 PM

Copy link
Contributor

@brandonc brandonc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ 👇

internal/backend/remote/backend_common.go Outdated Show resolved Hide resolved
Copy link
Contributor

@brandonc brandonc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some peculiar things about this error that I feel compelled to point out that make this bug fix a little less than straightforward.

We are colorizing (that is, replace [color] codes with terminal escape sequences that produce color in a terminal) the text of an error message and returning it as an error type.

The original intent of the error diagnostics are to basically format errors like this:

Screenshot 2024-01-16 at 4 55 25 PM

Specifically, a red bar prefixing a red label "Error:", followed by a white summary, followed by gray details.

By injecting escape codes into the details, we're hacking the error and overriding the intend of the diagnostics output.

If this error were instead used in JSON output, or just logged, or anything other than being displayed in the terminal, the escape characters wouldn't make sense and it would come out like { "error": { "details": "\x1b[1;33mTo view this run in a browser,..." }}

Maybe a better solution is to return an error message that does not "hack" the terminal, which may mean using a string that is not runHeader

@laurenolivia laurenolivia force-pushed the laurenolivia/fix-cloud-colorize branch from 3ed0e0c to 048818b Compare January 17, 2024 21:42
@laurenolivia laurenolivia changed the title [TF-11813] call Colorize() on CLI output [TF-11813] do not colorize runHeader when returned as err Jan 17, 2024
internal/backend/remote/backend_common.go Show resolved Hide resolved
internal/cloud/backend_common.go Show resolved Hide resolved
internal/cloud/backend_plan.go Outdated Show resolved Hide resolved
@laurenolivia laurenolivia merged commit 072dfbd into main Jan 17, 2024
6 checks passed
Copy link
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2024
@laurenolivia
Copy link
Contributor Author

changelog added via #34715

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants