Skip to content

PHPStan > Update baseline#4

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

PHPStan > Update baseline#4
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 1 ignored errors.

Keep it up all! 💪

There are only 9070 ignored errors left 😅

@github-actions github-actions Bot force-pushed the phpstan-baseline branch 7 times, most recently from aca7842 to 0f5c49a Compare January 22, 2025 12:26
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 8 times, most recently from 3a10989 to ffe2321 Compare January 30, 2025 12:26
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 7 times, most recently from 4d99ff2 to 6b8fc6b Compare February 6, 2025 12:27
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 4 times, most recently from 65fc14e to a99fcfc Compare February 10, 2025 12:26
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 4 times, most recently from 70a5eb0 to 831e62c Compare March 10, 2025 12:27
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 7 times, most recently from 1c213be to 269bafc Compare March 17, 2025 12:27
@github-actions github-actions Bot force-pushed the phpstan-baseline branch 4 times, most recently from 2c041cb to 76d02bb Compare March 21, 2025 12:27
loxK pushed a commit that referenced this pull request May 19, 2026
…ant) (Dolibarr#38300)

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

  TypeError: Argument #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