[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

Command icon 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

breidert created an issue. See original summary.

harivansh’s picture

a.dmitriiev made their first commit to this issue’s fork.

a.dmitriiev’s picture

Component: ...to be triaged » AI Observability
Status: Active » Needs review

Thank 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.

a.dmitriiev’s picture

Title: Use UTF-8 when truncating strings » Use UTF-8 safe functions when summarizing request messages
marcus_johansson’s picture

marcus_johansson’s picture

Issue tags: +needs forward port
marcus_johansson’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Chicago2026

Mbstring is a requirment for Drupal so this should be all good: https://www.drupal.org/docs/getting-started/system-requirements/php-requ...

marcus_johansson’s picture

Status: Reviewed & tested by the community » Fixed

Merged and added to 1.2.x, 1.3.x, 1.4.x and 2.x.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • a.dmitriiev committed 20c8ac18 on 3574181-assistant-agent-form
    fix: #3580767 use UTF-8 safe string functions