Add support for CLI-formatted errors and allow for dead code elimination#114
Closed
fheinecke wants to merge 1 commit into
Closed
Add support for CLI-formatted errors and allow for dead code elimination#114fheinecke wants to merge 1 commit into
fheinecke wants to merge 1 commit into
Conversation
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
rosstimothy
requested changes
Jan 30, 2025
Contributor
rosstimothy
left a comment
There was a problem hiding this comment.
As discussed offline, I don't think this is the right approach to solving the problem.
Contributor
|
I believe this was superseded by #118 |
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.
The current
DebugReporthas a couple of issues:The error message fields are HTML-escaped. This makes them difficult to read in a CLI context, especially anywhere we do something like
trace.Errorf("some error message: %q", "some relevant information"). Here's an example of what a debug report can currently produce:Error messages "bubbled up" through many layers in Teleport can have significantly more escaping, making logs painful to read.
Using the golang templating removes the possibility of dead code elimination, because it calls
reflect.MethodByName.This PR adds a new interface (for backwards compatibility), which adds separate HTML and CLI debug report functions. The HTML versions produce identical error messages as the (now depreciated)
DebugReport()functions. The CLI versions produce messages in the same format, but without any escaping.The PR also changes the underlying templating implementation to use a string builder rather than a template. This makes the code slightly harder to read, but removes the reflection dependency. While this is unlikely to make any different in Teleport product binaries, it should reduce the binary size of some of our internal tools. It should have a positive impact on the ~600 non-Gravitational consumers of this library as well.