Skip to content

Commit 5949dd4

Browse files
authored
fix(util): don't include filename in "Hidden Unicode" warning (renovatebot#41468)
fix(logger): don't include filename in "Hidden Unicode" warning As noted in renovatebot#41467, if a repository has many files with these warnings, the Dependency Dashboard can be flooded, which can reduce the utility, especially if some of these may be false positives. We can remove the filename from the WARN message, which will ensure that only a single message is logged. However, this will reduce the utility of the log message, as then users need to check their logs to see the `file`.
1 parent 441acb6 commit 5949dd4

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/util/fs/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ describe('util/fs/index', () => {
132132
// NOTE that we cannot test that this is called once across multiple `readLocalFile` as we're mocking the logger, so we're testing that it's called, not validating the nubmer of times
133133
expect(logger.logger.once.warn).toHaveBeenCalledWith(
134134
{ file: 'file.txt', hiddenCharacters: '\\u00A0\\u200D' },
135-
'Hidden Unicode characters have been discovered in the file `file.txt`. Please confirm that they are intended to be there, as they could be an attempt to "smuggle" text into your codebase, or used to confuse tools like Renovate or Large Language Models (LLMs)',
135+
'Hidden Unicode characters have been discovered in file(s) in your repository. See your Renovate logs for more details. Please confirm that they are intended to be there, as they could be an attempt to "smuggle" text into your codebase, or used to confuse tools like Renovate or Large Language Models (LLMs)',
136136
);
137137
});
138138

@@ -162,7 +162,7 @@ describe('util/fs/index', () => {
162162

163163
expect(logger.logger.once.warn).toHaveBeenCalledWith(
164164
{ file: 'example.csproj', hiddenCharacters: '\\uFEFF\\u200B' },
165-
'Hidden Unicode characters have been discovered in the file `example.csproj`. Please confirm that they are intended to be there, as they could be an attempt to "smuggle" text into your codebase, or used to confuse tools like Renovate or Large Language Models (LLMs)',
165+
'Hidden Unicode characters have been discovered in file(s) in your repository. See your Renovate logs for more details. Please confirm that they are intended to be there, as they could be an attempt to "smuggle" text into your codebase, or used to confuse tools like Renovate or Large Language Models (LLMs)',
166166
);
167167
});
168168
});

lib/util/git/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ describe('util/git/index', { timeout: 10000 }, () => {
615615

616616
expect(logger.logger.once.warn).toHaveBeenCalledWith(
617617
{ file: 'Dockerfile', hiddenCharacters: '\\u00A0' },
618-
'Hidden Unicode characters have been discovered in the file `Dockerfile`. Please confirm that they are intended to be there, as they could be an attempt to "smuggle" text into your codebase, or used to confuse tools like Renovate or Large Language Models (LLMs)',
618+
'Hidden Unicode characters have been discovered in file(s) in your repository. See your Renovate logs for more details. Please confirm that they are intended to be there, as they could be an attempt to "smuggle" text into your codebase, or used to confuse tools like Renovate or Large Language Models (LLMs)',
619619
);
620620
});
621621
});

lib/util/unicode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function logWarningIfUnicodeHiddenCharactersInPackageFile(
2323
file,
2424
hiddenCharacters: toUnicodeEscape(hiddenCharacters.join('')),
2525
},
26-
`Hidden Unicode characters have been discovered in the file \`${file}\`. Please confirm that they are intended to be there, as they could be an attempt to "smuggle" text into your codebase, or used to confuse tools like Renovate or Large Language Models (LLMs)`,
26+
`Hidden Unicode characters have been discovered in file(s) in your repository. See your Renovate logs for more details. Please confirm that they are intended to be there, as they could be an attempt to "smuggle" text into your codebase, or used to confuse tools like Renovate or Large Language Models (LLMs)`,
2727
);
2828
}
2929
}

0 commit comments

Comments
 (0)