mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 11:59:29 +00:00
fix: validate v0 history entries against SpawnRecordSchema (#2279)
The v0 fallback path in loadHistory() returned raw parsed JSON array directly without validating individual elements. This could cause TypeErrors (e.g. r.agent.toLowerCase() on undefined) in callers like getActiveServers and filterHistory when corrupted entries exist. Now filters each element through v.safeParse(SpawnRecordSchema, el), matching the validation the v1 path already performs. Fixes #2277 Agent: code-health Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
7643b96266
commit
0ef8eb4467
2 changed files with 2 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@openrouter/spawn",
|
||||
"version": "0.15.7",
|
||||
"version": "0.15.8",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"spawn": "cli.js"
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ export function loadHistory(): SpawnRecord[] {
|
|||
|
||||
// v0 format: bare array (pre-versioning; migrated to v1 on next write)
|
||||
if (Array.isArray(raw)) {
|
||||
return raw;
|
||||
return raw.filter((el) => v.safeParse(SpawnRecordSchema, el).success);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue