Skip to content

Fix incorrect method call in updateExpTextProcessingTime()#334

Open
printminion-co wants to merge 1 commit intonextcloud:mainfrom
IONOS-Productivity:fix/processing_time_exception
Open

Fix incorrect method call in updateExpTextProcessingTime()#334
printminion-co wants to merge 1 commit intonextcloud:mainfrom
IONOS-Productivity:fix/processing_time_exception

Conversation

@printminion-co
Copy link

This commit fixes a bug where the method updateExpTextProcessingTime incorrectly called getExpImgProcessingTime. The change ensures that text and image processing times are tracked independently.

Description

Fixes a bug in updateExpTextProcessingTime() where it incorrectly calls getExpImgProcessingTime() instead of getExpTextProcessingTime(). This causes database type conflicts when processing text generation tasks.

The Bug

File: lib/Service/OpenAiAPIService.php
Line: 850

The function reads image processing time configuration when it should read text processing time configuration:

public function updateExpTextProcessingTime(int $runtime): void {
    $oldTime = floatval($this->getExpImgProcessingTime());  // ❌ Wrong method
    // ...
}

This causes a mismatch between:

  • Read: openai_image_generation_time / localai_image_generation_time
  • Write: openai_text_generation_time / localai_text_generation_time

Impact

Error Message

RuntimeException: OpenAI/LocalAI request failed: conflict with value type from database

When it Occurs

  • Background job processing for TaskProcessing text generation tasks
  • All text-based AI operations (FreePrompt, Summary, Headline, etc.)
  • Both OpenAI and LocalAI endpoints affected

Affected Versions

  • Introduced in v3.6.0 (commit e1ffaba - "psalm fixes", April 4, 2025)
  • Present in all subsequent versions through current v4.2.0

The Fix

Change line 850 to call the correct method:

  public function updateExpTextProcessingTime(int $runtime): void {
-     $oldTime = floatval($this->getExpImgProcessingTime());
+     $oldTime = floatval($this->getExpTextProcessingTime());
      $newTime = (1.0 - Application::EXPECTED_RUNTIME_LOWPASS_FACTOR) * $oldTime + Application::EXPECTED_RUNTIME_LOWPASS_FACTOR * floatval($runtime);

Root Cause

Copy-paste error when updateExpTextProcessingTime() was created. The corresponding updateExpImgProcessingTime() method (line 774) correctly calls getExpImgProcessingTime(), but this pattern wasn't updated for the text processing variant.

Testing

The fix ensures:

  1. Text processing time metrics are properly tracked
  2. No database type conflicts when reading/writing config values
  3. Proper exponential moving average calculation for text generation times

Reproduction

  1. Configure LocalAI or OpenAI endpoint
  2. Trigger any text generation task via Assistant
  3. Background job worker processes the task
  4. Error occurs when trying to update processing time metrics

Stack Trace Context

File: /var/www/html/lib/private/TaskProcessing/Manager.php:949
  -> OCA\OpenAi\TaskProcessing\TextToTextProvider->process()

File: /var/www/html/apps-external/integration_openai/lib/TaskProcessing/TextToTextProvider.php:135
  -> RuntimeException: OpenAI/LocalAI request failed: conflict with value type from database

Checklist

  • Bug fix (non-breaking change which fixes an issue)
  • Tested locally
  • One-line change, minimal risk
  • No new dependencies
  • Maintains backward compatibility

This commit fixes a bug where the method updateExpTextProcessingTime incorrectly called getExpImgProcessingTime. The change ensures that text and image processing times are tracked independently.

Additionally, unit tests have been added to verify the correct functionality of processing time tracking for both text and image generations.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant