500 internal server error using 'suggest topic title' AI helper

AI-generated summary

Frully reports a new 500 Internal Server Error occurring specifically when using the ‘suggest topic title’ AI helper in Discourse. The issue is isolated to this feature, as other AI capabilities (proofreading, markdown generation, tagging, embeddings, and semantic search) function correctly.

The user is running a self-hosted instance of v2026.10.0-latest +401 on a DigitalOcean droplet, utilizing serverless inference with Deepseek 3.2 via a DO endpoint.

The error logs indicate a NoMethodError: undefined method 'flatten' for an instance of String. The stack trace points to the failure originating in:

  • /var/www/discourse/plugins/discourse-ai/lib/ai_helper/assistant.rb:202 within DiscourseAi::AiHelper::Assistant#generate_and_send_prompt
  • Triggered by DiscourseAi::AiHelper::AssistantController#suggest_title

The error suggests that the code expects an array (to which .flatten can be applied) but is receiving a string instead, likely during the processing of the AI response.

Related topics are similar but this seems new. All other related topics marked solved.

TLDR: 500 error when suggesting a topic title.
(proofread, generate markdown table, suggest tags, embedding, search/semantic all work fine)
Self hosted v2026.10.0-latest +401, Digitalocean droplet and serverless inference, Deepseek 3.2 via DO endpoint.

Logs generate error:

Failed to process hijacked response correctly : NoMethodError : undefined method 'flatten' for an instance of String
/var/www/discourse/plugins/discourse-ai/lib/ai_helper/assistant.rb:202:in 'DiscourseAi::AiHelper::Assistant#generate_and_send_prompt' 
/var/www/discourse/plugins/discourse-ai/app/controllers/discourse_ai/ai_helper/assistant_controller.rb:65:in 'block in DiscourseAi::AiHelper::AssistantController#suggest_title' 
/var/www/discourse/lib/hijack.rb:68:in 'BasicObject#instance_eval' 
/var/www/discourse/lib/hijack.rb:68:in 'block (2 levels) in Hijack#hijack' 
i18n-1.14.8/lib/i18n.rb:354:in 'I18n::Base#with_locale' 
/var/www/discourse/lib/hijack.rb:68:in 'block in Hijack#hijack' 
concurrent-ruby-1.3.8/lib/concurrent-ruby/concurrent/promises.rb:911:in 'Concurrent::Promises::Event#callback_on_resolution' 
concurrent-ruby-1.3.8/lib/concurrent-ruby/concurrent/promises.rb:797:in 'Concurrent::Promises::AbstractEventFuture#call_callback' 
concurrent-ruby-1.3.8/lib/concurrent-ruby/concurrent/promises.rb:803:in 'Concurrent::Promises::AbstractEventFuture#call_callbacks' 
concurrent-ruby-1.3.8/lib/concurrent-ruby/concurrent/promises.rb:692:in 'Concurrent::Promises::AbstractEventFuture#resolve_with' 
concurrent-ruby-1.3.8/lib/concurrent-ruby/concurrent/promises.rb:1331:in 'Concurrent::Promises::ResolvableEvent#resolve' 
/var/www/discourse/lib/scheduler/defer.rb:135:in 'block in Scheduler::Deferrable#do_work' 
rails_multisite-9.0.0/lib/rails_multisite/connection_management/null_instance.rb:54:in 'RailsMultisite::ConnectionManagement::NullInstance#with_connection'
rails_multisite-9.0.0/lib/rails_multisite/connection_management.rb:23:in 'RailsMultisite::ConnectionManagement.with_connection'
/var/www/discourse/lib/scheduler/defer.rb:130:in 'Scheduler::Deferrable#do_work' 
/var/www/discourse/lib/scheduler/defer.rb:116:in 'block (2 levels) in Scheduler::Deferrable#start_thread' 

Let me know if there is any more info I can add.