PHPStan > Update baseline#1
Open
github-actions[bot] wants to merge 1 commit into
Open
Conversation
e2e9ddd to
7a38153
Compare
77c38f1 to
58e6da6
Compare
da3e6b5 to
adc4212
Compare
88d2f1b to
3e3c5db
Compare
3e3c5db to
559d052
Compare
73d2aea to
e6dc913
Compare
e6dc913 to
35c1859
Compare
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.
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 3 ignored errors.
Keep it up all! 💪
There are only 4644 ignored errors left 😅