Error: Please use a valid role: user, model

Created on 28 August 2025, 2 months ago

Problem/Motivation

The generateContent endpoint called from \Drupal\ai_provider_google_vertex\Plugin\AiProvider\VertexProvider::chat is returning

Please use a valid role: user, model.

I tracked it down to the line: 'role' => ($message->getRole() === 'assistant') ? 'model' : $message->getRole() as one of my messages has the role tool.

Additionally, finding the real error was very difficult thanks to code like \Drupal\ai_provider_google_vertex\Plugin\AiProvider\VertexProvider::throwError which rather than just throwing Unknown Error: Could not get a response from the model this should throw a more obvious error to help debugging

🐛 Bug report
Status

Active

Version

1.1

Component

Code

Created by

🇬🇧United Kingdom intrafusion Edinburgh, UK

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

Comments & Activities

Production build 0.71.5 2024