{"record":{"id":"3c6ff41a3731f887","repo":"sgl-project/sglang","slug":"unknown-type-type-other","errorCode":null,"errorMessage":"Unknown type: {type(other)}","messagePattern":"Unknown type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/lang/interpreter.py","lineNumber":503,"sourceCode":"            self._execute_variable(other)\n        elif isinstance(other, SglVarScopeBegin):\n            self._execute_var_scope_begin(other)\n        elif isinstance(other, SglVarScopeEnd):\n            self._execute_var_scope_end(other)\n        elif isinstance(other, SglCommitLazy):\n            self._execute_commit_lazy_operations(other)\n        elif isinstance(other, SglConcateAndAppend):\n            if (\n                global_config.enable_parallel_encoding\n                and self.backend.support_concate_and_append\n            ):\n                self._execute_concatenate_and_append_kv_cache(other)\n            else:\n                self._execute_concatenate_and_append_text(other)\n        elif isinstance(other, SglSeparateReasoning):\n            self._execute_separate_reasoning(other)\n        else:\n            raise ValueError(f\"Unknown type: {type(other)}\")\n\n    def _execute_fill(self, value: str, prefix=False):\n        value = str(value)\n\n        if (\n            self.cur_role == \"assistant\"\n            and self.num_api_spec_tokens is not None\n            and self.backend.is_chat_model\n            and not prefix\n        ):\n            self.backend.spec_fill(value)\n            return\n\n        if self.speculated_text.startswith(value):\n            self.speculated_text = self.speculated_text[len(value) :]\n        else:\n            self.speculated_text = \"\"\n","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/lang/interpreter.py#L485-L521","documentation":"Raised by the SGL program interpreter's _execute when submit()/`+=` receives an object that is not one of the recognized SGL primitives (str, SglGen, SglSelect, SglImage, SglConcateAndAppend, SglSeparateReasoning, etc.). It is a dispatch failure: the value type is unsupported in a program statement.","triggerScenarios":"Doing `state += obj` or state.stream_executor.submit(obj) with an arbitrary Python object (dict, int, custom class) instead of a string or Sgl primitive; passing a primitive added in a newer sglang version to an older interpreter.","commonSituations":"See trigger scenarios.","solutions":["Convert the value to a string or use the appropriate Sgl* class (SglGen for generation, SglSelect for choices, SglImage for images)","Upgrade/downgrade sglang so the primitive class matches between the API that built the object and the interpreter executing it","Check the object is not None (None also falls through to this branch)"],"exampleFix":"# before\nstate += {\"role\": \"user\", \"text\": \"hi\"}   # dict is not supported\n# after\nstate += \"hi\"                            # plain text\n# or\nstate += SglGen(\"hi\", sampling_params={...})","handlingStrategy":"type-guard","validationCode":"from sglang.lang.ir import SglGen, SglSelect, SglImage\nALLOWED = (str, SglGen, SglSelect, SglImage)\ndef appendable(v) -> bool:\n    return isinstance(v, ALLOWED) and v is not None","typeGuard":"def is_sgl_primitive(v) -> bool:\n    from sglang.lang.ir import SglGen, SglSelect, SglImage\n    return isinstance(v, (str, SglGen, SglSelect, SglImage))","tryCatchPattern":"try:\n    state += value\nexcept ValueError as e:\n    if \"Unknown type\" in str(e):\n        state += str(value)  # coerce fallback\n    else:\n        raise","preventionTips":["Only append str or Sgl* primitives to a state","Coerce unknown payloads with str() as a fallback","Match sglang versions between code that builds and executes programs"],"tags":["type-error","interpreter","dsl","validation"],"backgroundTag":"unsupported-operand-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}