Information Extractor Problem: Failed to parse. "```json

Hi, everybody. I using the information extractor node to get structured data from a text. The curious thing is that it sometimes doesn’t work and I get this error:

Failed to parse. “”```json { …

I googled it and apparently some people have been having this and someone suspects it’s related to Langchain. But the entries are over a year old and nobody seems to have a solution for this.

Has anybody else encountered this issue and have a suggestion for me? I am using OpenAI 4o mini for the information extractor.

Running the version 1.71.3 on Coolify with postgres

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @Laius

It would help if you could post the entire error message.
When I’ve seen these types of errors, it’s usually because of null or “empty” values which haven’t been accounted for in the JSON schema.

For example, consider the following schema. All looks good but perhaps address_line_2 is optional and has no value.

{
  "type": "object",
  "properties": {
     "address_line_1": { "type": "string" },
     "address_line_2": { "type": "string" }
   }
}

// AI returns
// {
//    "address_line_1": "10 downing street",
//    "address_line_2": null
// }

This would throw a parsing error because the schema dictates that address_line_2 must be a string type. One way to solve this is to either ask the AI to default to an empty string or use a enum data type that includes null

{
  "type": "object",
  "properties": {
     "address_line_1": { "type": "string" },
     "address_line_2": { "type": ["string", "null"] }
   }
}