[Tracker]
Update Summary: [One-line status update for stakeholders]
Short Description: [One-line issue summary for stakeholders]
Check-in Date: MM/DD/YYYY
Metadata is used by the AI Tracker. Docs and additional fields here.
[/Tracker]
Problem/Motivation
When using as logger_db and logger as backend for observability, saving fails because of wrongly encoded data is passed to the backend.
The promble comes from the method summarizeAiPayloadData which uses substr instead of mb_substr when truncating the payload for logging.
Steps to reproduce (required for bugs, but not feature requests)
Please provide information like AI modules enabled, which AI provider, browser, etc.
Install logger_db and logger. Perform an AI operation with long text. Observe the wrongly encoded truncated text which causes the logger to fail.
Proposed resolution
Replace string manipulation functions with UTF-8 safe alternatives.
AI usage (if applicable)
[ ] AI Assisted Issue
This issue was generated with AI assistance, but was reviewed and refined by the creator.
[ ] AI Assisted Code
This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.
[ ] AI Generated Code
This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.
[ ] Vibe Coded
This code was generated by an AI and has only been functionally tested.
Issue fork ai-3580767
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
harivansh commentedBoth issue requirement are overlapping https://www.drupal.org/project/ai/issues/3566762
Comment #5
a.dmitriiev commentedThank you @harivansh for pointing this out. I have noticed that in the related issue the method is not yet changed to use the UTF-8 safe string functions, so I still opened a MR here with the changes that do not conflict with the current version of MR in #3566762: Improve summarizer for AI request input and output data for logs and spans. Feel free also to include the same changes in that MR if it is easier.
Comment #6
a.dmitriiev commentedComment #7
marcus_johansson commentedComment #8
marcus_johansson commentedComment #9
marcus_johansson commentedMbstring is a requirment for Drupal so this should be all good: https://www.drupal.org/docs/getting-started/system-requirements/php-requ...
Comment #13
marcus_johansson commentedMerged and added to 1.2.x, 1.3.x, 1.4.x and 2.x.