Field too long to be stored in name field?

Created on 20 February 2024, 9 months ago
Updated 6 March 2024, 8 months ago

Problem/Motivation

I've been using the Open AI interpolator to create some media/images. (Thanks very much. This is great.) I wanted to report this error that gets in the way when the body field is too big to be used in {{context}}. Is it possible to create a truncation option that will keep the first N characters as well as strip out the HTML?

I've been working around this by creating a shorter field and truncating the fields separately.


A general error happened why trying to interpolate, message SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'name' at row 1: INSERT INTO "media_field_data" ("mid", "vid", "bundle", "langcode", "status", "uid", "name", "thumbnail__target_id", "thumbnail__alt", "thumbnail__title", "thumbnail__width", "thumbnail__height", "created", "changed", "default_langcode", "revision_translation_affected") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array ( [:db_insert_placeholder_0] => 52 [:db_insert_placeholder_1] => 52 [:db_insert_placeholder_2] => image [:db_insert_placeholder_3] => en [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => 30 [:db_insert_placeholder_6] =>  

[[.....several thousand characters....]]

 [:db_insert_placeholder_7] => 141 [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => [:db_insert_placeholder_10] => 1792 [:db_insert_placeholder_11] => 1024 [:db_insert_placeholder_12] => 1708435990 [:db_insert_placeholder_13] => 1708435990 [:db_insert_placeholder_14] => 1 [:db_insert_placeholder_15] => 1 )

 
πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bogdog400

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

Comments & Activities

  • Issue created by @bogdog400
  • πŸ‡©πŸ‡ͺGermany marcus_johansson

    Hi @bogdog400 - Thank you for using the module and for reporting the bug. I will look into this right away.

    The idea to use the prompt as a media name made sense so it was easy to find it again, but I never realized that the prompts can be longer then a varchar. I will first off do what you write, and truncate automatically when its over 250 chars.

  • Status changed to Fixed 9 months ago
  • πŸ‡©πŸ‡ͺGermany marcus_johansson

    This is fixed in the dev branch and will be part of the next beta release, thanks again.

  • πŸ‡ΊπŸ‡ΈUnited States bogdog400

    Thanks. I'll download it and check it out.

  • πŸ‡ΊπŸ‡ΈUnited States bogdog400

    I downloaded the dev version, but it doesn't seem to work. No images are being created for some reason. And there are no errors in the log file. The next two days are pretty jammed so I can't dive deeper now. Just wanted to let you know in case it's something obvious.

    Thanks very much for everything.

  • πŸ‡ΊπŸ‡ΈUnited States bogdog400

    I went a bit deeper. The problem seems to come when I set the {{context}} to be the body field of the node. It works fine with the title. When I set the {{context}} to body, it saves the node very quickly and doesn't seem to make any attempt to contact OpenAI.

  • πŸ‡©πŸ‡ͺGermany marcus_johansson

    Ah, thanks for looking into it. I think the problem is missing error handling better. It might be that the body is either too large context or that the moderation tool is blocking it, because you have some word/sentence in there that will not be allowed by OpenAI.

    It was on the roadmap already - basically documentation and error handling (messages + logging) is the two large parts missing before taking the main module and the OpenAI plugin into production ready status.

    I will most likely have time to fix this on Friday. Until then, you could try a shorter body or look for words that might go against OpenAIs content policies.

    Also if your body is an actual article, its better to first generate a hidden image generation prompt from it and then use this to generate the video. Check this video, but just use DALL-E instead of DreamStudio: https://workflows-of-ai.com/workflow/header-image-generation

  • πŸ‡ΊπŸ‡ΈUnited States bogdog400

    No worries whatsoever. Don't rush on my account. I'm just grateful you're working on this with such speed. Thank you.

    BTW, I just got this error again. (See below.)

    I upgraded AI Interpolator. Here's the composer message:

     - Upgrading drupal/ai_interpolator (1.0.0-beta2 => dev-1.0.x bc41295)
    

    But I notice now that the Open AI module wasn't updated by Composer.

    Machine name: ai_interpolator_openai
    Version: 1.0.0-beta1
    Requires: AI InterpolatorOpenAI Core
    Required by: AI Interpolator Address
    
    

    Could that be the source of my error? I'm going to try to upgrade the other modules too to dev. Maybe that will fix things.

    Thanks.

    SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'name' at row 1: INSERT INTO "media_field_data" ("mid", "vid", "bundle", "langcode", "status", "uid", "name", "thumbnail__target_id", "thumbnail__alt", "thumbnail__title", "thumbnail__width", "thumbnail__height", "created", "changed", "default_langcode", "revision_translation_affected") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array ( [:db_insert_placeholder_0] => 72 [:db_insert_placeholder_1] => 72 [:db_insert_placeholder_2] => image [:db_insert_placeholder_3] => en [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] =>

    [[.... about 400 characters ... ]]

    [:db_insert_placeholder_7] => 161 [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => [:db_insert_placeholder_10] => 1792 [:db_insert_placeholder_11] => 1024 [:db_insert_placeholder_12] => 1708525165 [:db_insert_placeholder_13] => 1708525165 [:db_insert_placeholder_14] => 1 [:db_insert_placeholder_15] => 1 )

  • πŸ‡ΊπŸ‡ΈUnited States bogdog400

    After upgrading the Open AI module too to dev, the problem disappeared. Thx!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024