directus-labs / directus-labs/directus-template-cli

Template Install MySQL 8.4 - type / content mismatch

Open
#74 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
191
Forks
37
PR merge metrics
No merged PRs in 30d

Description

Current Behaviour

The usage of npx directus-template-cli@latest apply results in errors but partially installed collections without finished relations and missing content.

Expected Behaviour

The template is installed and no errors happen during installation

Specifications

Directus 11.4
MySQL 8.4.4
Template: agencyos / simplecms
Collation of all tables (also newly added): utf8mb4
Connection with admin api key and email/pass

Error Log


[14:39:14] POST /collections 200 47ms
[14:39:14.709] ERROR: Unexpected token '_', "_utf8mb4\'[]\'" is not valid JSON
    err: {
      "type": "SyntaxError",
      "message": "Unexpected token '_', \"_utf8mb4\\'[]\\'\" is not valid JSON",
      "stack":
tcms_nginx         | 192.168.155.1 - - [24/Jan/2025:14:39:14 +0000] "POST /collections HTTP/1.1" 200 554 "-" "node" "-"
          SyntaxError: Unexpected token '_', "_utf8mb4\'[]\'" is not valid JSON
              at JSON.parse (<anonymous>)
              at parseJSON (file:///directus/node_modules/.pnpm/@directus+utils@file+packages+utils_vue@3.5.13_typescript@5.7.3_/node_modules/@directus/utils/dist/shared/index.js:131:15)
              at castToObject (file:///directus/node_modules/.pnpm/@directus+api@file+api_@types+node@22.10.5_@unhead+vue@1.11.15_vue@3.5.13_typescript@5.7.3____rwsrw2ii2kgfeysgzcibtnsnku/node_modules/@directus/api/dist/utils/get-default-value.js:47:20)
              at getDefaultValue (file:///directus/node_modules/.pnpm/@directus+api@file+api_@types+node@22.10.5_@unhead+vue@1.11.15_vue@3.5.13_typescript@5.7.3____rwsrw2ii2kgfeysgzcibtnsnku/node_modules/@directus/api/dist/utils/get-default-value.js:21:20)
              at file:///directus/node_modules/.pnpm/@directus+api@file+api_@types+node@22.10.5_@unhead+vue@1.11.15_vue@3.5.13_typescript@5.7.3____rwsrw2ii2kgfeysgzcibtnsnku/node_modules/@directus/api/dist/utils/get-schema.js:111:35
              at file:///directus/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/mapValues.js:38:34
              at file:///directus/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createBaseFor.js:17:11
              at baseForOwn (file:///directus/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseForOwn.js:13:20)
              at mapValues (file:///directus/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/mapValues.js:37:3)
              at getDatabaseSchema (file:///directus/node_modules/.pnpm/@directus+api@file+api_@types+node@22.10.5_@unhead+vue@1.11.15_vue@3.5.13_typescript@5.7.3____rwsrw2ii2kgfeysgzcibtnsnku/node_modules/@directus/api/dist/utils/get-schema.js:108:21)
    }
[15:02:46.293] ERROR: alter table `block_gallery` add primary key `block_gallery_pkey`(`id`) - Multiple primary key defined
    err: {
      "type": "Error",
      "message": "alter table `block_gallery` add primary key `block_gallery_pkey`(`id`) - Multiple primary key defined",
      "stack":
          Error: alter table `block_gallery` add primary key `block_gallery_pkey`(`id`) - Multiple primary key defined
              at Packet.asError (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/packets/packet.js:740:17)
              at Query.execute (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/commands/command.js:29:26)
              at Connection.handlePacket (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/base/connection.js:475:34)
              at PacketParser.onPacket (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/base/connection.js:93:12)
              at PacketParser.executeStart (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/packet_parser.js:75:16)
              at Socket.<anonymous> (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/base/connection.js:100:25)
              at Socket.emit (node:events:524:28)
              at addChunk (node:internal/streams/readable:561:12)
              at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
              at Readable.push (node:internal/streams/readable:392:5)
      "code": "ER_MULTIPLE_PRI_KEY",
      "errno": 1068,
      "sqlState": "42000",
      "sqlMessage": "Multiple primary key defined",
      "sql": "alter table `block_gallery` add primary key `block_gallery_pkey`(`id`)",
      "extensions": {
        "stack":
            Error: alter table `block_gallery` add primary key `block_gallery_pkey`(`id`) - Multiple primary key defined
                at Packet.asError (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/packets/packet.js:740:17)
                at Query.execute (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/commands/command.js:29:26)
                at Connection.handlePacket (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/base/connection.js:475:34)
                at PacketParser.onPacket (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/base/connection.js:93:12)
                at PacketParser.executeStart (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/packet_parser.js:75:16)
                at Socket.<anonymous> (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/base/connection.js:100:25)
                at Socket.emit (node:events:524:28)
                at addChunk (node:internal/streams/readable:561:12)
                at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
                at Readable.push (node:internal/streams/readable:392:5)
      }
    }

Additionally and maybe helpful. The fourth value inserted is the breaking one. '_utf8mb4\'{}\'' - The fourth column is command_palette_settings in this case. Maybe related

Warning: Directus Error: insert into `directus_settings` (`auth_login_attempts`, `auth_password_policy`, `basemaps`,
 ›   `command_palette_settings`, `custom_aspect_ratios`, `custom_css`, `default_appearance`, `default_language`, `default_theme_dark`,
 ›   `default_theme_light`, `id`, `mapbox_key`, `module_bar`, `project_color`, `project_descriptor`, `project_logo`, `project_name`,
 ›   `project_url`, `public_background`, `public_favicon`, `public_foreground`, `public_note`, `public_registration`,
 ›   `public_registration_email_filter`, `public_registration_role`, `public_registration_verify_email`, `report_bug_url`,
 ›   `report_error_url`, `report_feature_url`, `storage_asset_presets`, `storage_asset_transform`, `storage_default_folder`,
 ›   `theme_dark_overrides`, `theme_light_overrides`) values (25, '/^.{8,}$/', NULL, '_utf8mb4\\\'{}\\\'', NULL,
Other Tests
Error does not occur with postgresql db
MySQL 5 Other error. Same problem
Error: create table `globals` (`description` text null, `id` char(36) not null, `social_links` json null default ('[]'), `tagline` varchar(255) null, `title` varchar(255) null, `url` varchar(255) null, `favicon` char(36) null, `logo` char(36) null, `openai_api_key` varchar(255) null, `directus_url` varchar(255) null, `logo_dark_mode` char(36) null, `accent_color` varchar(255) null, primary key (`id`)) - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('[]'), `tagline` varchar(255) null, `title` varchar(255) null, `url` varchar(25' at line 1
              at Packet.asError (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/packets/packet.js:740:17)
              at Query.execute (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/commands/command.js:29:26)
              at Connection.handlePacket (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/base/connection.js:475:34)
              at PacketParser.onPacket (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/base/connection.js:93:12)
              at PacketParser.executeStart (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/packet_parser.js:75:16)
              at Socket.<anonymous> (/directus/node_modules/.pnpm/mysql2@3.12.0/node_modules/mysql2/lib/base/connection.js:100:25)
              at Socket.emit (node:events:524:28)
              at addChunk (node:internal/streams/readable:561:12)
              at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
              at Readable.push (node:internal/streams/readable:392:5)
      "code": "ER_PARSE_ERROR",
      "errno": 1064,
      "sqlState": "42000"
Issue with json null default ('[]')

The utf8mb4 error occurs only while installing the directus_settings command palette JSON which is not in valid format `'_utf8mb4\'{}\''.

The other issue is that the primary keys will be updated every time so mysql throws an error as they would be duplications.

Warning: Directus Error: alter table `pages` add primary key `pages_pkey`(`id`) - Multiple primary key defined (Status: 500)
 ›   {"code":"INTERNAL_SERVER_ERROR","stack":"Error: alter table `pages` add primary key `pages_pkey`(`id`) - Multiple primary ke

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing npx directus-template-cli@latest apply with the agencyos/simplecms template on MySQL 8.4, then inspect handling of the directus_settings command palette JSON and schema creation for globals, pages, and block_gallery. Done means installation completes without JSON or SQL errors, duplicate primary-key updates, or missing relations and content; compare behavior with PostgreSQL and MySQL 5 as reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, typescript
Domain
cli, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.