Skip to content

Commit 3faafc8

Browse files
committed
style(config): tighten ignored-provider-fields warn
1 parent 23eeb79 commit 3faafc8

1 file changed

Lines changed: 15 additions & 25 deletions

File tree

‎src/config/settings.ts‎

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,9 +1039,9 @@ function settingsSchemaError(path: string): Error {
10391039
// Provider blocks from some external tools carry fields Corbits does not
10401040
// honor: compat.supportsReasoningEffort, supportsThinkingTokenBudget,
10411041
// thinkingLevelMap, samplingParams. ProviderSettingsSchema does not reject
1042-
// unknown keys, so they pass validation and are silently dropped. Warn when
1043-
// any are present so the ignore is never silent. CL-10226 (Part 1): the field
1044-
// mappings themselves are separate follow-ups — this only surfaces the warn.
1042+
// unknown keys, so they pass validation and are silently dropped. Warn so the
1043+
// ignore is never silent. CL-10226 (Part 1): field mappings are a separate
1044+
// follow-up — this only surfaces the warn.
10451045
const IGNORED_PROVIDER_FIELDS: {
10461046
key: string;
10471047
path: (p: Record<string, unknown>) => unknown;
@@ -1054,31 +1054,19 @@ const IGNORED_PROVIDER_FIELDS: {
10541054
{ key: "samplingParams", path: (p) => p.samplingParams },
10551055
{
10561056
key: "compat.supportsReasoningEffort",
1057-
path: (p) =>
1058-
typeof p.compat === "object" &&
1059-
p.compat !== null &&
1060-
(p.compat as Record<string, unknown>).supportsReasoningEffort !==
1061-
undefined
1062-
? (p.compat as Record<string, unknown>).supportsReasoningEffort
1063-
: undefined,
1057+
path: (p) => {
1058+
const compat = p.compat as Record<string, unknown> | undefined;
1059+
return compat?.supportsReasoningEffort;
1060+
},
10641061
},
10651062
];
10661063

1067-
function warnOnIgnoredProviderFields(providers: unknown): void {
1068-
if (
1069-
providers === undefined ||
1070-
typeof providers !== "object" ||
1071-
providers === null
1072-
) {
1073-
return;
1074-
}
1075-
for (const [name, provider] of Object.entries(
1076-
providers as Record<string, unknown>,
1077-
)) {
1078-
if (typeof provider !== "object" || provider === null) continue;
1079-
const p = provider as Record<string, unknown>;
1064+
function warnOnIgnoredProviderFields(
1065+
providers: Record<string, Record<string, unknown>>,
1066+
): void {
1067+
for (const [name, provider] of Object.entries(providers)) {
10801068
const present = IGNORED_PROVIDER_FIELDS.filter(
1081-
(field) => field.path(p) !== undefined,
1069+
(field) => field.path(provider) !== undefined,
10821070
).map((field) => field.key);
10831071
if (present.length > 0) {
10841072
process.stderr.write(
@@ -1093,7 +1081,9 @@ function normalizeParsedSettings(path: string, parsed: unknown): Settings {
10931081
throw settingsSchemaError(path);
10941082
}
10951083
const s = parsed as unknown as Record<string, unknown>;
1096-
warnOnIgnoredProviderFields(s.providers);
1084+
warnOnIgnoredProviderFields(
1085+
s.providers as Record<string, Record<string, unknown>>,
1086+
);
10971087
// These keys were removed when plugins moved to discovery; they are now
10981088
// silently dropped on the next save. Warn so a user who relied on them knows
10991089
// to re-enable the equivalent plugins in /plugins instead of losing the

0 commit comments

Comments
 (0)