{"record":{"id":"f82c79e346123b3f","repo":"sgl-project/sglang","slug":"structure-info-not-used-for-json-schema-constraint","errorCode":null,"errorMessage":"structure_info not used for JSON schema constraints","messagePattern":"structure_info not used for JSON schema constraints","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/function_call/json_array_parser.py","lineNumber":51,"sourceCode":"        raise NotImplementedError(\n            \"Detect and parse not supported for JSON schema constraints.\"\n        )\n\n    def parse_streaming_increment(\n        self, new_text: str, tools: List[Tool]\n    ) -> StreamingParseResult:\n        \"\"\"\n        Streaming incremental parsing with tool validation.\n        \"\"\"\n        return super().parse_streaming_increment(new_text, tools)\n\n    def structure_info(self) -> callable:\n        \"\"\"\n        Return a function that creates StructureInfo for constrained generation.\n        This is not used for JSON schema constraints as they are handled\n        by the constraint backends directly.\n        \"\"\"\n        raise NotImplementedError(\"structure_info not used for JSON schema constraints\")\n","sourceCodeStart":33,"sourceCodeEnd":52,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/function_call/json_array_parser.py#L33-L52","documentation":"Raised by JsonArrayParser.structure_info() because JSON-array function-call parsers do not provide a StructureInfo factory; JSON-schema constraints are handled directly by the constraint backends (e.g. xgrammar/outlines) instead. Calling this method on this parser subclass is a programming error, not a runtime data problem.","triggerScenarios":"Calling .structure_info() on a JsonArrayParser instance (or any code path that assumes every FunctionCallParser implements structure_info) while using the JSON array tool-call format.","commonSituations":"New code that iterates over tool parsers and unconditionally calls structure_info(); switching a server to the json_array parser type while retaining logic written for chat-template/structural-tag parsers like KimiK3.","solutions":["Guard the call with hasattr(parser, 'structure_info') or check parser type before calling","Use a parser that implements structure_info (e.g. a structural-tag-based detector) if constrained-generation StructureInfo is required","Refactor the call site to only invoke structure_info on parsers that declare it"],"exampleFix":"// before\ninfo = parser.structure_info()\n// after\nif not isinstance(parser, JsonArrayParser):\n    info = parser.structure_info()","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def has_structure_info(p) -> bool:\n    return hasattr(p, \"structure_info\") and not isinstance(p, JsonArrayParser)","tryCatchPattern":null,"preventionTips":["Check parser type before calling optional parser APIs","Treat structure_info as opt-in per parser family"],"tags":["function-call","not-implemented","json-schema","parser"],"backgroundTag":"not-implemented-method-misuse","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}