{"record":{"id":"6730eed71a786db8","repo":"musistudio/claude-code-router","slug":"message-6730ee","errorCode":null,"errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/web/management-server.ts","lineNumber":1518,"sourceCode":"      return \"text/javascript; charset=utf-8\";\n    case \".jpg\":\n    case \".jpeg\":\n      return \"image/jpeg\";\n    case \".png\":\n      return \"image/png\";\n    case \".svg\":\n      return \"image/svg+xml\";\n    case \".webp\":\n      return \"image/webp\";\n    default:\n      return \"application/octet-stream\";\n  }\n}\n\nfunction readRequiredString(value: unknown, message: string): string {\n  const text = readString(value);\n  if (!text) {\n    throw new Error(message);\n  }\n  return text;\n}\n\nfunction readString(value: unknown): string | undefined {\n  return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction readEnvString(key: string): string | undefined {\n  return readString(process.env[key]);\n}\n\nfunction readEnvPort(key: string): number | undefined {\n  const value = Number(process.env[key]);\n  return Number.isInteger(value) && value > 0 && value < 65536 ? value : undefined;\n}\n\nfunction pluginIdValue(value: string | undefined): string {","sourceCodeStart":1500,"sourceCodeEnd":1536,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/web/management-server.ts#L1500-L1536","documentation":"A generic required-string validation error thrown by readRequiredString in the management server. The helper trims the incoming value and rejects anything that is not a non-empty string; the interpolated message names the specific field that failed (e.g. 'sessionId is required.'). It exists to fail fast when JSON-RPC/HTTP request payloads are missing mandatory string fields.","triggerScenarios":"Sending a request payload to a management server endpoint where a required string field is undefined, null, a non-string type, an empty string, or a whitespace-only string.","commonSituations":"A client omits an optional-looking field from the request body; a field is sent as a number or object instead of a string; trimmed whitespace (e.g. '\" \\t\"') sneaks in from form input.","solutions":["Check the error message text — it names the exact missing field; add that field as a non-empty trimmed string to your request payload.","Ensure the field is serialized as a JSON string, not a number/boolean/object.","Trim client-side input and reject empty values before sending the request."],"exampleFix":"// before\nawait api.createSession({ sessionId: \"\", label: 42 });\n\n// after\nawait api.createSession({ sessionId: \"session-1\", label: \"42\" });","handlingStrategy":"validation","validationCode":"const payload = { sessionId: String(raw.sessionId ?? \"\").trim() };\nif (!payload.sessionId) throw new Error(\"sessionId missing — fix the form before submitting\");\nawait api.call(payload);","typeGuard":"function hasRequiredString<T extends string>(o: unknown, key: T): o is Record<T, string> { return typeof (o as any)?.[key] === \"string\" && (o as any)[key].trim().length > 0; }","tryCatchPattern":"try { await api.call(payload); } catch (e) { if (e instanceof Error && /is required\\.$/.test(e.message)) { /* e.message names the missing field; fix payload */ } throw e; }","preventionTips":["Build payloads from typed interfaces","Trim and assert required strings before the request","Surface field-level errors to the UI"],"tags":["validation","required-field","request-payload"],"backgroundTag":"missing-required-field","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}