{"record":{"id":"e61145216c3ea07d","repo":"HKUDS/nanobot","slug":"field-must-be-a-string","errorCode":null,"errorMessage":"{field} must be a string","messagePattern":"(.+?) must be a string","errorType":"validation","errorClass":"TypeError","httpStatus":400,"severity":"error","filePath":"nanobot/api/server.py","lineNumber":146,"sourceCode":"    return str(value)\n\n\ndef _as_str(value: object) -> str:\n    \"\"\"Return *value* when it is text, otherwise an empty string.\"\"\"\n    return value if isinstance(value, str) else \"\"\n\n\ndef _require_json_object(value: object, field: str) -> dict[str, Any]:\n    \"\"\"Validate an object-valued field from an untrusted JSON request.\"\"\"\n    if not isinstance(value, dict):\n        raise TypeError(f\"{field} must be an object\")\n    return cast(dict[str, Any], value)\n\n\ndef _require_json_string(value: object, field: str) -> str:\n    \"\"\"Validate a string-valued field from an untrusted JSON request.\"\"\"\n    if not isinstance(value, str):\n        raise TypeError(f\"{field} must be a string\")\n    return value\n\n\n# ---------------------------------------------------------------------------\n# SSE helpers\n# ---------------------------------------------------------------------------\n\n\ndef _sse_chunk(delta: str, model: str, chunk_id: str, finish_reason: str | None = None) -> bytes:\n    \"\"\"Format a single OpenAI-compatible SSE chunk.\"\"\"\n    payload = {\n        \"id\": chunk_id,\n        \"object\": \"chat.completion.chunk\",\n        \"created\": int(time.time()),\n        \"model\": model,\n        \"choices\": [\n            {\n                \"index\": 0,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/api/server.py#L128-L164","documentation":"Error \"{field} must be a string\" thrown in HKUDS/nanobot.","triggerScenarios":"Thrown at nanobot/api/server.py:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"42f37dc4c0e409eac7818a82d165c5f2757bc075","analyzedAt":"2026-08-26T00:18:52.276Z","schemaVersion":2},"datasetVersion":"2026-08-26T04:18:47.238Z"}