Skip to content

[BUG/QUESTION] JSON Structured Output (Type: JSON Array) always fails with "additionalProperties must have a type" #4502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
iparker opened this issue May 26, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@iparker
Copy link

iparker commented May 26, 2025

Hi team,

I'm trying to use the "JSON Structured Output" feature in a LLM node in Flowise. Specifically, I select Type: JSON Array and then provide a schema.

However, no matter which schema I use – even minimal or official examples – the node always fails immediately with the following error:

Error in LLM node: 400 Invalid schema for response_format 'extract': In context=('properties', 'jobPosting', 'items', 'additionalProperties'), schema must have a 'type' key.

What I tried

Multiple valid schemas, including:

  • Manually created minimal schemas
  • Schemas with and without additionalProperties
  • Schemas with only type, properties, required, items

Even the official example schema from https://json-schema.org/learn/json-schema-examples#job-posting

All result in the exact same error – even before the LLM is queried

Minimal example (that fails immediately)

{
  "jobPosting": {
    "type": "array",
    "items": {
      "type": "object",
      "properties": {
        "basicData": {
          "type": "object",
          "properties": {
            "title": { "type": "string" },
            "period": {
              "type": "object",
              "properties": {
                "startDate": { "type": "string" },
                "endDate": { "type": "string" }
              },
              "required": ["startDate", "endDate"]
            },
            "locations": {
              "type": "array",
              "items": { "type": "string" }
            },
            "workingTimes": { "type": "string" }
          },
          "required": ["title", "period", "locations"]
        },
        "personnelRequirement": {
          "type": "object",
          "properties": {
            "numberOfPersons": { "type": "integer" },
            "activity": {
              "type": "array",
              "items": { "type": "string" }
            },
            "salary": { "type": "string" },
            "additionalInfo": { "type": ["string", "null"] }
          },
          "required": ["numberOfPersons", "activity", "salary"]
        }
      },
      "required": ["basicData", "personnelRequirement"]
    }
  }
}

Expected
The schema should be accepted and used to extract structured values from the LLM output, or at least allow testing without error.

Actual
The LLM node fails immediately on save, and I cannot proceed. The error always references additionalProperties, even if it's not part of the schema.

Question

  • Is there a strict internal schema format expected beyond JSON Schema Draft-07?
  • Is this a known issue with the JSON Array type in "JSON Structured Output"?

If possible, could you please provide a working example of the schema format that is expected in this context?

Thanks in advance for any help or clarification!

@iparker
Copy link
Author

iparker commented May 26, 2025

Update / Additional Info – enum appears to break schema validation

While further testing, I discovered that the schema validation fails as soon as an enum is added inside an array of objects, even if everything else remains the same.

✅ This version works perfectly (no enum):

{
  "jobPosting": {
    "type": "array",
    "items": {
      "type": "object",
      "properties": {
        "title": { "type": "string" },
        "startDate": { "type": "string" },
        "endDate": { "type": "string" },
        "locations": {
          "type": "array",
          "items": { "type": "string" }
        },
        "workingTimes": { "type": "string" },
        "numberOfPersons": { "type": "number" },
        "activity": {
          "type": "array",
          "items": { "type": "string" }
        },
        "salary": { "type": "string" },
        "additionalInfo": { "type": "string" }
      }
    }
  }
}

❌ As soon as I add an enum inside activity.items, it fails:

"activity": {
  "type": "array",
  "items": {
    "type": "string",
    "enum": ["activity.flyerverteiler", "activity.verkostung"]
  }
}

This produces the same error again:

Error in LLM node: 400 Invalid schema for response_format 'extract':
In context=('properties', 'jobPosting', 'items', 'additionalProperties'), schema must have a 'type' key.

Even trying to work around this with:

"additionalProperties": { "type": "object" }

…does not resolve the issue reliably.

My suspicion

It looks like the enum keyword triggers internal validation logic that expects the surrounding object to define additionalProperties with a type, and if that's not present, it fails – even if additionalProperties is not needed or defined.

This is very likely a bug (or undocumented restriction) in Flowise's schema handling (possibly inherited from LangChain or Pydantic).

Request

Could you please clarify:

  • Is using enum in object-array properties supported?
  • If yes, what’s the exact shape required to avoid this additionalProperties/type error?

Happy to provide a reproducible Flowise flow or LLM node setup if needed.

@HenryHengZJ HenryHengZJ added the bug Something isn't working label May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants