PHPStan > Update baseline#4
Open
github-actions[bot] wants to merge 1 commit into
Open
Conversation
aca7842 to
0f5c49a
Compare
3a10989 to
ffe2321
Compare
4d99ff2 to
6b8fc6b
Compare
65fc14e to
a99fcfc
Compare
70a5eb0 to
831e62c
Compare
1c213be to
269bafc
Compare
2c041cb to
76d02bb
Compare
76d02bb to
237a7d7
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 😅