Fix: Add type safety to models status command (#16395)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 1554137ae3
Co-authored-by: BinHPdev <219093083+BinHPdev@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
Bin Deng
2026-02-15 03:07:38 +08:00
committed by GitHub
parent 01ec81dae4
commit 4734f99108
2 changed files with 4 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ Docs: https://docs.openclaw.ai
- Cron: repair missing/corrupt `nextRunAtMs` for the updated job without globally recomputing unrelated due jobs during `cron update`. (#15750) - Cron: repair missing/corrupt `nextRunAtMs` for the updated job without globally recomputing unrelated due jobs during `cron update`. (#15750)
- Discord: prefer gateway guild id when logging inbound messages so cached-miss guilds do not appear as `guild=dm`. Thanks @thewilloftheshadow. - Discord: prefer gateway guild id when logging inbound messages so cached-miss guilds do not appear as `guild=dm`. Thanks @thewilloftheshadow.
- TUI: refactor searchable select list description layout and add regression coverage for ANSI-highlight width bounds. - TUI: refactor searchable select list description layout and add regression coverage for ANSI-highlight width bounds.
- Models/CLI: guard `models status` string trimming paths to prevent crashes from malformed non-string config values. (#16395) Thanks @BinHPdev.
## 2026.2.14 ## 2026.2.14

View File

@@ -107,7 +107,7 @@ export async function modelsStatusCommand(
const imageFallbacks = typeof imageConfig === "object" ? (imageConfig?.fallbacks ?? []) : []; const imageFallbacks = typeof imageConfig === "object" ? (imageConfig?.fallbacks ?? []) : [];
const aliases = Object.entries(cfg.agents?.defaults?.models ?? {}).reduce<Record<string, string>>( const aliases = Object.entries(cfg.agents?.defaults?.models ?? {}).reduce<Record<string, string>>(
(acc, [key, entry]) => { (acc, [key, entry]) => {
const alias = entry?.alias?.trim(); const alias = typeof entry?.alias === "string" ? entry.alias.trim() : undefined;
if (alias) { if (alias) {
acc[alias] = key; acc[alias] = key;
} }
@@ -127,7 +127,7 @@ export async function modelsStatusCommand(
); );
const providersFromConfig = new Set( const providersFromConfig = new Set(
Object.keys(cfg.models?.providers ?? {}) Object.keys(cfg.models?.providers ?? {})
.map((p) => p.trim()) .map((p) => (typeof p === "string" ? p.trim() : ""))
.filter(Boolean), .filter(Boolean),
); );
const providersFromModels = new Set<string>(); const providersFromModels = new Set<string>();
@@ -176,7 +176,7 @@ export async function modelsStatusCommand(
...providersFromEnv, ...providersFromEnv,
]), ]),
) )
.map((p) => p.trim()) .map((p) => (typeof p === "string" ? p.trim() : ""))
.filter(Boolean) .filter(Boolean)
.toSorted((a, b) => a.localeCompare(b)); .toSorted((a, b) => a.localeCompare(b));