fix: avoid object stringification in session labels

This commit is contained in:
Peter Steinberger
2026-01-09 16:57:50 +01:00
parent be48233bc4
commit d0b06b4334

View File

@@ -37,7 +37,12 @@ function invalid(message: string): { ok: false; error: ErrorShape } {
function normalizeLabel(
raw: unknown,
): { ok: true; label: string } | ReturnType<typeof invalid> {
const trimmed = String(raw ?? "").trim();
const trimmed =
typeof raw === "string"
? raw.trim()
: typeof raw === "number" || typeof raw === "boolean"
? String(raw).trim()
: "";
if (!trimmed) return invalid("invalid label: empty");
if (trimmed.length > SESSION_LABEL_MAX_LENGTH) {
return invalid(`invalid label: too long (max ${SESSION_LABEL_MAX_LENGTH})`);