refactor(lint): enforce err key for errors in logger metadata - #45759
Open
secustor wants to merge 3 commits into
Open
refactor(lint): enforce err key for errors in logger metadata#45759secustor wants to merge 3 commits into
secustor wants to merge 3 commits into
Conversation
…r-err-key # Conflicts: # tools/lint/rules.ts # tools/lint/rules/logger-static-message.ts
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.
Changes
Errors passed to the logger were stored under two different metadata keys,
erranderror. Bunyan only runs the error serializer (stack handling, credential redaction) for theerrkey, and having two keys makes error logs harder to search.This PR makes
errthe single key and enforces it:renovate/logger-err-key. It flags anerrororexceptionmetadata key whose value looks like an error object (an identifier or member named like an error, ornew SomeError()), in every logger call and at every log level, includinglogger.once.*. It is auto-fixable and rewrites the key toerr, emitting the shorthand{ err }where the value is already namederr. It also flags{ error: err.message }and{ error: err.stack }, and the fix replaces the property byerr: <error>so the whole error is logged through the serializer. Other string values such as{ error: err.code }are left alone.error-key check out ofrenovate/logger-static-messageinto the new rule, so that rule only checks for static messages. The shared logger-call helpers now live intools/lint/utils/logger.ts.lib/**and fixes the 16 existing violations across 14 files: 13{ error: parsed.error }style calls in manager and datasource parsers, twologger.fatal({ error: err.stack })calls in the config file parsers, and one{ error: error.message }in the deb datasource.docs/development/best-practices.md.Context
Please select one of the following:
AI assistance disclosure
Did you use AI tools to create any part of this pull request?
Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.
The lint rule, its tests, the refactor of
logger-static-message, the code fixes and the documentation update were written by Claude Fable 5.1 via Claude Code, directed and reviewed by @secustor.Use of AI in replying to PR comments
Who answers review comments:
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via:
The public repository: