Invalid schema for unexpected JSON (text) field size 16384

Created on 18 October 2025, 17 days ago

Problem/Motivation

A project had JSON (text) fields of size 16K. With recent JSON Field, installs of the codebase using drush --existing-config began to fail with:

 [error]  Unexpected error during import with operation create for field.storage.node.field_data: Exception thrown while performing a schema update. SQLSTATE[HY000]: General error: 4161 Unknown data type: 'NOT': CREATE TABLE "node__field_data" (
"bundle" VARCHAR(128) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance', 
"deleted" TINYINT NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted', 
"entity_id" INT unsigned NOT NULL COMMENT 'The entity id this data is attached to', 
"revision_id" INT unsigned NOT NULL COMMENT 'The entity revision id this data is attached to', 
"langcode" VARCHAR(32) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT 'The language code for this data item.', 
"delta" INT unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields', 
"field_data_value"  NOT NULL, 
PRIMARY KEY ("entity_id", "deleted", "delta", "langcode"), 
INDEX "bundle" ("bundle"), 
INDEX "revision_id" ("revision_id")
) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT 'Data storage for node field field_data.'; Array
(
)

Table generation statements were invalid as the field schema was not being generated correctly for field sizes other than \Drupal\json_field\Plugin\Field\FieldType\JsonItem::SIZE_SMALL, SIZE_NORMAL, SIZE_MEDIUM or SIZE_BIG. Setting a column type is required.

Steps to reproduce

Install from --existing-config using config like:

langcode: en
status: true
dependencies:
  module:
    - json_field
    - node
id: node.field_data
field_name: field_data
entity_type: node
type: json
settings:
  size: 16384
module: json_field
locked: false
cardinality: -1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

Proposed resolution

Ensure that \Drupal\json_field\Plugin\Field\FieldType\JsonItem::schema returns a valid schema by providing a default value.

I see this relates to πŸ› Field length limit logic is incorrect Active and that another user has reported issues with the update script there on sites with existing data. I haven't tested with existing data.

Remaining tasks

- Test coverage
- Fix

User interface changes

none

API changes

none

Data model changes

Storage schema contains required keys.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand xurizaemon Ōtepoti, Aotearoa 🏝

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024