Skip to content

PHPStan > Update baseline#1

Open
github-actions[bot] wants to merge 1 commit into
developfrom
phpstan-baseline
Open

PHPStan > Update baseline#1
github-actions[bot] wants to merge 1 commit into
developfrom
phpstan-baseline

Conversation

@github-actions
Copy link
Copy Markdown

This PR is automatically created to cleanup our baseline.

Since the last refresh of the baseline we have fixed 3 ignored errors.

Keep it up all! 💪

There are only 4644 ignored errors left 😅

@github-actions github-actions Bot force-pushed the phpstan-baseline branch 8 times, most recently from e2e9ddd to 7a38153 Compare April 3, 2026 12:22
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 7 times, most recently from 77c38f1 to 58e6da6 Compare April 10, 2026 12:25
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 7 times, most recently from da3e6b5 to adc4212 Compare April 17, 2026 12:28
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 7 times, most recently from 88d2f1b to 3e3c5db Compare April 24, 2026 12:30
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 4 times, most recently from 73d2aea to e6dc913 Compare April 29, 2026 12:40
priojk pushed a commit that referenced this pull request May 30, 2026
…ant) (Dolibarr#38300)

Two bugs combined to make UniversalLLMAdapter::__construct() crash with:

  TypeError: Argument Dolibarr#4 ($model) must be of type string, array given

at parse_intent.php line 301 when the user-configured model wasn't
properly read.

(1) Wrong shape assumption -- getListOfAIServices() declares model
defaults as a NESTED array of the form:

    $servicesList[$key]['textgeneration'] = ['default' => 'model-name']

The previous code read $servicesList[$key]['textgeneration'] (without
['default']) and got the inner array back. That array was then passed
as the $defModel fallback to a (string)-typed constructor argument.

(2) Wrong constant -- the admin UI ("Prompt and custom AI models" tab
in setup.php) stores the per-function model under
AI_API_<SERVICE>_MODEL_TEXT, matching the convention already used by
Ai::generateContent() for the same data. The previous code read
AI_API_<SERVICE>_MODEL (no _TEXT suffix), which is never written by
that form. So the user-configured model was silently ignored and we
fell back to the (array) default from bug #1.

Together these two bugs reliably reproduced the TypeError on any
default install of the AI module where the user had set a custom
text model via the admin UI.

This patch:

- Walks $servicesList[$key]['textgeneration'] correctly (extracting
  ['default'] when it's an array, accepting strings for backward
  compat).
- Tries AI_API_<SERVICE>_MODEL_TEXT first (the constant the admin
  UI writes), and falls back to the legacy AI_API_<SERVICE>_MODEL
  for compatibility with anyone who might have set it manually.
- Defensively coerces the final value to a string and falls back to
  the default if for any reason it's still not a string.

Tested with google (gemini-2.5-flash) and chatgpt configured via
the admin UI -> UniversalLLMAdapter receives a string and the
AI request goes through.
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.

0 participants