SQLSTATE[22001]: String data, right truncated error on long file paths

Created on 3 May 2024, about 2 months ago
Updated 15 May 2024, about 2 months ago

Problem/Motivation

When inserting long file paths into the filebrowser_content table, the operation fails with a "String data, right truncated" error if the path exceeds the maximum length allowed for the 'path' column. This issue occurs specifically when the path length exceeds the column's set character limit, preventing the storage of long file paths which is common in structured directory systems.

Error message:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'path' at row 1: INSERT INTO "filebrowser_content" ("nid", "root", "path", "file_data") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3);

Steps to reproduce

Navigate to the file browser interface.
Attempt to upload or reference a file with an exceptionally long path (greater than the set limit for the 'path' column in the database).

Expected Behavior

The module should handle long paths gracefully, either by truncating the path with proper notification or by allowing larger values in the database column.

Actual Behavior

The operation fails with an SQL error due to the path length exceeding the column's capacity.

Proposed resolution

Consider evaluating and increasing the maximum length of the 'path' column in the filebrowser_content table. Another approach might be to implement a check that warns the user or truncates the path before attempting to insert it into the database.

Additional info

  • Filebrowser module version: 3.0.1
  • Drupal version: 9.4.5
  • Database type and version: Mysql 5.7.44-48-log
  • PHP version: 7.4.33
🐛 Bug report
Status

Postponed: needs info

Version

3.1

Component

Directory Listing Pages

Created by

🇮🇹Italy sepa_cleversoft

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

Comments & Activities

  • Issue created by @sepa_cleversoft
  • 🇳🇱Netherlands clivesj

    My preference would be to increase the size of the "path" column.
    I thought 255 was already generous. Until now we didn't hit this limit. What size do you think is useful without increasing it too much?

    For the paths that are too long (with respect to the new limit) I will display an error notifying that that file is not added to the directory listing. Is this workable?

    I have changed the version to 3.1.x-dev since 3.0.1 is D9

  • Status changed to Postponed: needs info about 2 months ago
Production build 0.69.0 2024