From 846df4d60d3231250eb20e94f4d6435f8b1b20b6 Mon Sep 17 00:00:00 2001 From: Hephaestus Date: Sat, 23 May 2026 09:44:41 +0200 Subject: [PATCH] fix: remove dead serializeState + normalize PATCH error responses (#4051 #4057 follow-ups) Two audit cleanup items: 1. Remove dead serializeState() passthrough in local-storage.ts. Was just forwarding to serializeStateLightweight() with no callers. 2. Normalize PATCH /v1/sessions/:id error responses from reply.code() + return {} to reply.status().send() pattern matching all other routes. --- src/routes/sessions.ts | 6 ++---- src/services/acp/local-storage.ts | 8 -------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/routes/sessions.ts b/src/routes/sessions.ts index 4cf6acef..38bc9c02 100644 --- a/src/routes/sessions.ts +++ b/src/routes/sessions.ts @@ -590,13 +590,11 @@ export function registerSessionRoutes(app: FastifyInstance, ctx: RouteContext): updates.isPinned = body.isPinned; } if (Object.keys(updates).length === 0) { - reply.code(400); - return { error: 'No valid fields to update', code: 'INVALID_UPDATE' }; + return reply.status(400).send({ error: 'No valid fields to update', code: 'INVALID_UPDATE' }); } const updated = await sessions.updateSessionMetadata(session.id, updates); if (!updated) { - reply.code(404); - return { error: 'Session not found', code: 'NOT_FOUND' }; + return reply.status(404).send({ error: 'Session not found', code: 'NOT_FOUND' }); } return addActionHints(updated, sessions, channels); })); diff --git a/src/services/acp/local-storage.ts b/src/services/acp/local-storage.ts index 2e75d174..35c9b57f 100644 --- a/src/services/acp/local-storage.ts +++ b/src/services/acp/local-storage.ts @@ -944,14 +944,6 @@ function serializeStateLightweight(state: LocalState): SerializedState { }; } -/** - * Original serializeState kept for backward compat with the legacy cloneEvent path. - * Issue #4032: Only used by the persist path which now uses serializeStateLightweight. - */ -function serializeState(state: LocalState): SerializedState { - return serializeStateLightweight(state); -} - function deserializeState(value: unknown): LocalState { if (!isSerializedState(value)) { throw new Error('FileAcpLocalStorageProfile: invalid storage file');