Input type with Optional field breaks Playground #237

Open
opened 2026-02-16 00:19:42 -05:00 by yindo · 3 comments
Owner

Originally created by @jmaness on GitHub (Oct 16, 2024).

If a chain has an input type containing an optional field, the Playground page fails to load (blank page), and the following error is logged in the browser console:

index-400979f0.js:150 Uncaught Error: Unknown type: {"type":"null"}
    at VC (index-400979f0.js:150:3067)
    at Object.J6 [as uiSchema] (index-400979f0.js:150:3156)
    at bh (index-400979f0.js:148:40890)
    at index-400979f0.js:150:1495
    at Array.map (<anonymous>)
    at n0 (index-400979f0.js:150:1419)
    at index-400979f0.js:255:25928
    at z$ (index-400979f0.js:38:19538)
    at Uw (index-400979f0.js:40:3139)
    at p4 (index-400979f0.js:40:2351)

Example input type:

from pydantic import BaseModel
from typing import Optional


class Question(BaseModel):
    question: str
    datasource: Optional[str]

The generated input schema looks like:

{
  "properties": {
    "question": {
      "title": "Question",
      "type": "string"
    },
    "datasource": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Datasource"
    }
  },
  "required": [
    "question"
  ],
  "title": "Question",
  "type": "object"
}

and the {"type":"null"} seems to cause an issue with jsonforms.

Should the generated input schema be the following instead?

{
  "properties": {
    "question": {
      "title": "Question",
      "type": "string"
    },
    "datasource": {
      "type": "string"
      "title": "Datasource"
    }
  },
  "required": [
    "question"
  ],
  "title": "Question",
  "type": "object"
}
Originally created by @jmaness on GitHub (Oct 16, 2024). If a chain has an input type containing an optional field, the Playground page fails to load (blank page), and the following error is logged in the browser console: ``` index-400979f0.js:150 Uncaught Error: Unknown type: {"type":"null"} at VC (index-400979f0.js:150:3067) at Object.J6 [as uiSchema] (index-400979f0.js:150:3156) at bh (index-400979f0.js:148:40890) at index-400979f0.js:150:1495 at Array.map (<anonymous>) at n0 (index-400979f0.js:150:1419) at index-400979f0.js:255:25928 at z$ (index-400979f0.js:38:19538) at Uw (index-400979f0.js:40:3139) at p4 (index-400979f0.js:40:2351) ``` Example input type: ``` from pydantic import BaseModel from typing import Optional class Question(BaseModel): question: str datasource: Optional[str] ``` The generated input schema looks like: ``` { "properties": { "question": { "title": "Question", "type": "string" }, "datasource": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Datasource" } }, "required": [ "question" ], "title": "Question", "type": "object" } ``` and the `{"type":"null"}` seems to cause an issue with jsonforms. Should the generated input schema be the following instead? ``` { "properties": { "question": { "title": "Question", "type": "string" }, "datasource": { "type": "string" "title": "Datasource" } }, "required": [ "question" ], "title": "Question", "type": "object" } ```
Author
Owner

@jmaness commented on GitHub (Oct 16, 2024):

From reading through https://json-schema.org/understanding-json-schema/reference/object#required, it seems like the generated schema using anyOf and {"type":"null"} should be valid for optional properties, so perhaps this is a bug in jsonforms after all.

@jmaness commented on GitHub (Oct 16, 2024): From reading through https://json-schema.org/understanding-json-schema/reference/object#required, it seems like the generated schema using `anyOf` and `{"type":"null"}` should be valid for optional properties, so perhaps this is a bug in jsonforms after all.
Author
Owner

@tdakanalis commented on GitHub (Oct 25, 2024):

Any fix or workaround on this?

@tdakanalis commented on GitHub (Oct 25, 2024): Any fix or workaround on this?
Author
Owner

@eyurtsev commented on GitHub (Nov 5, 2024):

duplicate of: https://github.com/langchain-ai/langserve/issues/777

@eyurtsev commented on GitHub (Nov 5, 2024): duplicate of: https://github.com/langchain-ai/langserve/issues/777
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langserve#237