Ai Automators doesn't works with Queue/cron

Created on 17 September 2024, 3 days ago
Updated 19 September 2024, 1 day ago

Problem/Motivation

After running the CRON job, the field is not filled and the following two logs are created.

InvalidArgumentException: Field ai_automator_status is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 616 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

and

A general error happened why trying to interpolate, message Field ai_automator_status is unknown.

Steps to reproduce

Enable the AI Automator for a field.
Select Queue/Cron in Automator Worker option.
Create a new node where we have this field and the context.
Run Cron job.

🐛 Bug report
Status

Needs review

Version

1.0

Component

AI Automators

Created by

🇵🇹Portugal developer-rocha

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

Comments & Activities

  • Issue created by @developer-rocha
  • Assigned to Marcus_Johansson
  • 🇵🇹Portugal developer-rocha

    This patch addresses an issue when accessing the ai_automator_status field within the AutomatorFieldData.php file in the ai_automator module. Previously, the code used $entity->set('ai_automator_status', AiAutomatorStatusField::STATUS_FINISHED) to set the field status, which caused inconsistencies during the queue processing.

    The proposed solution replaces the field-setting method with a direct assignment, i.e., $entity->ai_automator_status = AiAutomatorStatusField::STATUS_FINISHED. This change ensures that the field is correctly updated when the queue status is changed to STATUS_FINISHED or STATUS_FAILED, maintaining the expected system behavior during entity saving.

    This adjustment improves stability and consistency in handling the ai_automator_status field within the queue processing.

  • 🇩🇪Germany Marcus_Johansson

    @developer-rocha This was a pretty bad oversight for me when moving the AI Interpolators third party settings to AI Automators config entities.

    When you add you first Automator Type to a enitity or entity/bundle that doesn't have one, it needs to create a field that is called AI Automator Status that is used for cron/queue or for API requests where you want to see when the processing is finished.

    The function that checked if this was needed to be added was still looking in third party settings. This has now been fixed with the following commits: https://git.drupalcode.org/project/ai/-/commit/f3f1da9e5b8ecdb3c2d067f71...

    The merge train is running, when that is done could you test this by downloading the latest dev package and:
    1. Resaving the field that has an Automator Type on it.
    2. That should make the field AI Automator Status show up.
    3. Now cron job should be possible.

    If that works, feel free to set to Fixed, otherwise set back to Needs Work.

  • Status changed to Needs review 1 day ago
Production build 0.71.5 2024