refactor(config): harden catchall hint mapping and array fallback

This commit is contained in:
Peter Steinberger
2026-02-24 00:59:44 +00:00
parent 30c622554f
commit 13478cc79a
4 changed files with 74 additions and 15 deletions

View File

@@ -17,15 +17,6 @@ function isEnvVarPlaceholder(value: string): boolean {
return ENV_VAR_PLACEHOLDER_PATTERN.test(value.trim());
}
function isExtensionPath(path: string): boolean {
return (
path === "plugins" ||
path.startsWith("plugins.") ||
path === "channels" ||
path.startsWith("channels.")
);
}
function isExplicitlyNonSensitivePath(hints: ConfigUiHints | undefined, paths: string[]): boolean {
if (!hints) {
return false;
@@ -130,9 +121,8 @@ function redactObjectWithLookup(
if (Array.isArray(obj)) {
const path = `${prefix}[]`;
if (!lookup.has(path)) {
if (!isExtensionPath(prefix)) {
return obj;
}
// Keep behavior symmetric with object fallback: if hints miss the path,
// still run pattern-based guessing for non-extension arrays.
return redactObjectGuessing(obj, prefix, values, hints);
}
return obj.map((item) => {
@@ -507,9 +497,8 @@ function restoreRedactedValuesWithLookup(
// sensitive string array in the config...
const { incoming: incomingArray, path } = arrayContext;
if (!lookup.has(path)) {
if (!isExtensionPath(prefix)) {
return incomingArray;
}
// Keep behavior symmetric with object fallback: if hints miss the path,
// still run pattern-based guessing for non-extension arrays.
return restoreRedactedValuesGuessing(incomingArray, original, prefix, hints);
}
return mapRedactedArray({