Skip to content

Go CLI: update list supported models - #15845

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
JinHai-CN:fix448
Jun 9, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
JinHai-CN:fix448

Conversation

@JinHai-CN

Copy link
Copy Markdown
Member

What problem does this PR solve?

Now list supported models will show more info.

RAGFlow(api/default)> list supported models from 'gitee' 'test';
+-----------+------------+-------------+----------------------------------------------------------+---------------------------------------------+
| dimension | max_tokens | model_types | name                                                     | thinking                                    |
+-----------+------------+-------------+----------------------------------------------------------+---------------------------------------------+
|           |            |             | Wan2.7                                                   |                                             |
|           |            |             | HappyHorse-1.0                                           |                                             |
|           |            |             | Qwen3.6-27B@Qwen                                         |                                             |
|           |            |             | Qwen3.6-35B-A3B@Qwen                                     |                                             |
|           | 1048576    | [chat]      | DeepSeek-V4-Flash@deepseek-ai                            | map[clear_thinking:true default_value:true] |
|           | 1048576    | [chat]      | DeepSeek-V4-Pro@deepseek-ai                              | map[clear_thinking:true default_value:true] |
+-----------+------------+-------------+----------------------------------------------------------+---------------------------------------------+

Type of change

  • New Feature (non-breaking change which adds functionality)

@coderabbitai

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors the model discovery API across 60+ model provider drivers, changing ListModels from returning raw model ID strings to returning structured ListModelResponse objects with metadata. Provider manager initialization is moved to a global singleton pattern. Optional MaxTokens and Dimension fields are added to the Model type, with nil-safe dereferencing throughout the service layer.

Changes

Model Listing API & Provider Manager Refactor

Layer / File(s) Summary
Core Model Types & Provider Manager Infrastructure
internal/entity/models/types.go, internal/entity/models/model.go, internal/dao/database.go
ModelDriver.ListModels signature changes from []string to []ListModelResponse. New ListModelResponse struct adds optional MaxTokens, ModelTypes, Thinking, and Dimension fields. Model.MaxTokens changes from int to *int, and Dimension *int field is added. Provider manager initialization refactored from factory-return pattern (NewProviderManager()) to global-state pattern with InitProviderManager(dir) error and GetProviderManager() accessor; database.go updates calls and variable types accordingly.
Service Layer ListModels Consumption & MaxTokens Nil-Safety
internal/service/model_service.go
ListSupportedModels now calls driver-provided ListModels, transforms ListModelResponse structs into response maps with model metadata, and returns []map[string]interface{} instead of []string. MaxTokens dereferencing is made nil-safe across GetModelConfigFromProviderInstance, getModelConfig, and multiple endpoint methods (UpdateModelStatus, ChatToModelWithMessages, etc.) by checking model.MaxTokens != nil before dereference and defaulting to 0 when nil. ShowModel return type changes from *entity.Model to *modelModule.Model.
HTTP Handler Response Shape
internal/handler/providers.go
ListInstanceModels with supported=true returns ListModelResponse objects directly in the response instead of transforming them into intermediate map[string]string structures with "model_name" fields.
All Model Driver ListModels Implementations (60+ providers)
internal/entity/models/{302ai,aliyun,anthropic,...,zhipu-ai}.go
Every provider driver's ListModels method updated to return []ListModelResponse instead of []string. Each implementation populates the Name field from the provider's model identifier (e.g., model.ID, model.name, model_name). Some drivers like Gitee and SiliconFlow additionally populate optional metadata fields (dimension, max_tokens, model_types, thinking) using GetProviderManager().GetModelByNameOrAlias(...).
Test Updates
internal/entity/models/model_test.go
Provider manager initialization updated from NewProviderManager(dir) (returning pm) to InitProviderManager(dir) followed by pm := GetProviderManager(). ModelDriver type assertions changed from imported aliased types (e.g., *modeldrivers.MinerUModel) to direct types (e.g., *MinerUModel).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes


Possibly related PRs

  • infiniflow/ragflow#15627: Overlapping refactor of the same ListModels implementations across model drivers and baseURL/baseModel wiring.
  • infiniflow/ragflow#15786: New list/show model CLI/HTTP flow depends on GetModelProviderManager() and model metadata that this PR refactors.
  • infiniflow/ragflow#14886: Implements ZhipuAIModel.ListModels which is directly impacted by this PR's interface/signature changes.

Suggested labels

☯️ refactor, size:XXL


Suggested reviewers

  • Haruko386

🐰 From the rabbit's desk:

Hopping through a hundred driver files,
Strings become Response structs with style,
MaxTokens now optional (nil-safe delight!),
And providers sing in singleton might! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Go CLI: update list supported models' clearly summarizes the main change - updating the CLI command for listing supported models with enhanced functionality.
Description check ✅ Passed The PR description addresses the required template sections: it explains the problem (showing more model info in list output), includes a concrete example of the new output format, and specifies the type of change (New Feature).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JinHai-CN JinHai-CN added the ci Continue Integration label Jun 9, 2026
@JinHai-CN
JinHai-CN marked this pull request as ready for review June 9, 2026 08:54
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels Jun 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 14

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/entity/models/model.go (1)

516-524: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Nil-pointer dereference when MaxTokens is nil.

model.MaxTokens is now a pointer and may be nil. Dereferencing it at line 518 without a nil check will cause a panic.

🐛 Proposed fix: add nil guard
 		case "max_tokens":
 			if maxVal, ok := filterValue.(int); ok {
-				if *model.MaxTokens < maxVal {
+				if model.MaxTokens == nil || *model.MaxTokens < maxVal {
 					matchFilter = false
 					resp.Code = 400
-					resp.Message = fmt.Sprintf("Model does not meet filter criteria: max_tokens (%d) < %d",
-						model.MaxTokens, maxVal)
+					if model.MaxTokens == nil {
+						resp.Message = fmt.Sprintf("Model does not meet filter criteria: max_tokens is not set")
+					} else {
+						resp.Message = fmt.Sprintf("Model does not meet filter criteria: max_tokens (%d) < %d",
+							*model.MaxTokens, maxVal)
+					}
 				}
 			}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/model.go` around lines 516 - 524, The "max_tokens"
filter case dereferences model.MaxTokens without a nil check causing a panic;
update the case in the filtering function to first check if model.MaxTokens ==
nil and, if so, set matchFilter = false and populate resp.Code and resp.Message
(e.g., explain max_tokens is missing), otherwise safely compare *model.MaxTokens
to maxVal and keep the existing logic that sets matchFilter = false and resp
fields when the value is too small; ensure you reference model.MaxTokens,
matchFilter, resp.Code and resp.Message when making the changes.
🧹 Nitpick comments (3)
internal/entity/models/model.go (2)

428-436: ⚡ Quick win

Inconsistent MaxTokens handling compared to ListAllModels.

ListAllModels (lines 381-383) conditionally includes max_tokens only when non-nil and dereferences it. Here, max_tokens is always included and may be nil. Consider aligning the behavior for consistent API responses.

♻️ Proposed fix: align with ListAllModels pattern
 	modelList := []map[string]interface{}{}
 	for _, model := range provider.Models {
 		modelData := map[string]interface{}{
 			"name":        model.Name,
-			"max_tokens":  model.MaxTokens,
 			"model_types": model.ModelTypes,
 		}
+		if model.MaxTokens != nil {
+			modelData["max_tokens"] = *model.MaxTokens
+		}
 		modelList = append(modelList, modelData)
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/model.go` around lines 428 - 436, The model
serialization here always includes "max_tokens" even if nil; update the loop in
the function that builds modelList to match ListAllModels' pattern by only
adding "max_tokens" when model.MaxTokens != nil and storing *model.MaxTokens
(dereferenced) instead of the pointer. Locate the loop over provider.Models
(where modelData is created) and change the map construction so "max_tokens" is
conditionally added when non-nil, keeping "name" and "model_types" unchanged.

296-300: 💤 Low value

Hardcoded path may reduce flexibility.

The path conf/all_models.json is hardcoded while provider configs use the dirPath parameter. Consider making this path configurable or deriving it relative to dirPath for consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/model.go` around lines 296 - 300, The code reads a
hardcoded "conf/all_models.json" via os.ReadFile which ignores the function's
dirPath parameter; change the file resolution to derive the config path from
dirPath (or accept a configurable path) before calling os.ReadFile so the
function uses filepath.Join(dirPath, "conf", "all_models.json") or a passed-in
filename; update the read call that assigns to data and err (the os.ReadFile
usage) to use the derived/configurable path and adjust any callers if you add a
parameter.
internal/entity/models/stepfun.go (1)

371-371: 💤 Low value

Consider pre-allocating slice capacity.

Since len(data) is known at this point, pre-allocating the slice capacity can avoid reallocation during append operations. Other drivers (tokenhub, tokenpony) follow this pattern.

♻️ Suggested optimization
-	models := make([]ListModelResponse, 0)
+	models := make([]ListModelResponse, 0, len(data))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/stepfun.go` at line 371, Pre-allocate the slice
capacity for models since len(data) is known: change the allocation of models
(type ListModelResponse) to reserve capacity using make with a third argument
(e.g., make([]ListModelResponse, 0, len(data))) or allocate directly with length
and fill by index; update places that append to models accordingly to avoid
repeated reallocations when iterating over data.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/entity/models/baidu.go`:
- Around line 798-805: The loop over result["data"] uses unchecked type
assertions and can panic; update the code that builds the models slice (the
block creating models := make([]ListModelResponse, 0) and iterating over
result["data"]) to safely assert types: first check that result["data"] exists
and is a []interface{} (with an ok check), then for each entry assert it is a
map[string]interface{} and safely extract "id" as a string (with ok checks)
before appending a ListModelResponse{Name: modelName}; if any check fails, skip
that entry (or handle gracefully) so the function (in baidu.go) never panics on
malformed API responses.

In `@internal/entity/models/gitee.go`:
- Around line 903-920: The lookup uses model.ID when calling
GetProviderManager().GetModelByNameOrAlias but the canonical name used later
includes the OwnedBy suffix; update the code to build the fully-qualified
modelName (using model.ID and model.OwnedBy) before calling
GetModelByNameOrAlias so the provider manager can find metadata for names like
"ModelID@OwnedBy"; then populate modelResponse from modelEntity as before
(fields: Dimension, MaxTokens, ModelTypes, Thinking) and append to models.
Ensure you still set modelResponse.Name to the final qualified name (model.ID +
"@" + model.OwnedBy when OwnedBy != "").

In `@internal/entity/models/huggingface.go`:
- Around line 514-519: The loop that builds []ListModelResponse uses unchecked
type assertions on result["data"], each element, and the "id" field which can
panic; update the code that iterates over result (used when building models) to
first check that result["data"] is a []interface{} (use a type assertion with
ok), then for each element assert it's a map[string]interface{} with ok, and
that modelMap["id"] is a string before appending to models (skip or continue on
invalid entries and optionally log the unexpected shapes); modify the block that
creates models and references modelMap/modelName/ListModelResponse accordingly
to use these guarded checks.

In `@internal/entity/models/jina.go`:
- Around line 358-363: The loop over result["data"] uses unchecked type
assertions and can panic; update the code that builds models (the slice of
ListModelResponse) to safely type-assert result["data"] to []interface{} (check
the ok boolean), iterate only if successful, for each element assert it is
map[string]interface{} (with an ok check), then extract "name" as a string with
an ok check before creating a ListModelResponse; on any failed assertion skip
the item and optionally log a warning (do not panic) so the driver remains
resilient.

In `@internal/entity/models/lmstudio.go`:
- Around line 564-569: The loop building models from result uses unchecked type
assertions and can panic; update the code that constructs the
[]ListModelResponse from result to first verify result["data"] is a
[]interface{} (using the comma-ok/type switch), then for each element assert it
is a map[string]interface{} and that map["id"] is a string (using comma-ok),
skipping or logging entries that fail validation instead of panicking; keep the
output type as []ListModelResponse and only append valid Name values to models
to preserve existing behavior.

In `@internal/entity/models/model_test.go`:
- Around line 138-143: After calling InitProviderManager(dir) you must obtain
the manager instance before using it; add a call to GetProviderManager() and
assign it to pm (e.g., pm := GetProviderManager()) immediately after
InitProviderManager returns, then use pm.FindProvider("CoHere") as intended so
pm is defined and the test compiles.
- Around line 288-293: After calling InitProviderManager(dir) you never obtain
the manager instance, causing pm to be undefined; add a call to
GetProviderManager() and assign it to pm (e.g., pm := GetProviderManager())
immediately after InitProviderManager(dir) so subsequent uses of pm
(FindProvider, etc.) compile; ensure the declaration is in the same scope as the
test assertions that reference pm.
- Around line 201-206: The test calls InitProviderManager(dir) but never assigns
pm; add pm := GetProviderManager() immediately after InitProviderManager(dir)
returns and before any use of pm so the subsequent calls to pm.FindProvider(...)
and other pm.* references (used in this file) compile; ensure you use the
package-level GetProviderManager function to obtain the manager instance and
then proceed with existing assertions.

In `@internal/entity/models/model.go`:
- Around line 394-402: GetModelByNameOrAlias lowercases the input but
Alias2ModelIndex is populated with original-case keys, causing lookups to fail
for mixed-case aliases; fix by normalizing keys when building Alias2ModelIndex
(ensure every alias inserted into ProviderManager.Alias2ModelIndex is
strings.ToLower(alias)) so GetModelByNameOrAlias can reliably lowercase the
input and find the index, or alternatively remove the lowercase call in
GetModelByNameOrAlias and perform lookup using the original alias case—update
the map construction code paths that populate Alias2ModelIndex (where aliases
are added) to use the normalized form, and keep GetModelByNameOrAlias using
strings.ToLower(modelName) as currently implemented.

In `@internal/entity/models/ollama.go`:
- Around line 519-523: The loop over result["models"] in ollama.go uses unsafe
type assertions and can panic; update the code that iterates over
result["models"] to use safe type assertions (check ok when casting
result["models"] to []interface{} and when casting each model to
map[string]interface{} and the "name" field to string), skip entries that fail
casts instead of panicking, and append valid names to ListModelResponse{Name:
...}; ensure you reference the existing variables/result map and the
ListModelResponse type so behavior stays consistent with other drivers (novita,
nvidia, openai).

In `@internal/entity/models/openrouter.go`:
- Around line 795-800: The loop building models from result["data"] uses
unchecked type assertions and can panic; update the code that iterates over
result["data"] to safely assert types (check ok values) for the top-level slice,
each element being a map[string]interface{}, and the "id" field being a string
before using them (symbols: result, models, ListModelResponse, modelMap,
modelName); skip or log invalid entries instead of asserting, and only append
ListModelResponse{Name: modelName} when all assertions succeed.

In `@internal/entity/models/orcarouter.go`:
- Around line 467-472: The loop blindly type-asserts result["data"] and each
model to concrete types which can panic; change the parsing in the
ListModelResponse construction to perform safe type checks (use a type assertion
with the "ok" idiom or a type switch) for result["data"] to ensure it's a
[]interface{}, for each model to ensure it's a map[string]interface{}, and for
the "id" field to ensure it's a string, skip or log entries that fail validation
instead of asserting; update the block that builds models (references: result,
models, modelMap, modelName, ListModelResponse) to only append when all checks
succeed.

In `@internal/entity/models/xunfei.go`:
- Around line 439-443: In ListModels, avoid unchecked type assertions on
result["data"] and its elements (currently producing modelMap :=
model.(map[string]interface{}) and modelMap["id"].(string)); instead validate
types with comma-ok checks and return a descriptive error if the payload shape
is unexpected (e.g., ensure result["data"] exists and is []interface{}, each
item is map[string]interface{}, and "id" is a string) before appending to the
models slice (ListModelResponse); update error handling to propagate a clear
error rather than allowing a panic.

In `@internal/service/model_service.go`:
- Around line 247-257: The slice result is left nil when modelList is empty,
causing JSON serialization to emit null; initialize result as an empty slice
(e.g. result := make([]map[string]interface{}, 0)) before the loop that iterates
modelList so you always return an empty array instead of nil from the function
that builds maps from model.Name, model.Dimension, model.MaxTokens,
model.ModelTypes, model.Thinking.

---

Outside diff comments:
In `@internal/entity/models/model.go`:
- Around line 516-524: The "max_tokens" filter case dereferences model.MaxTokens
without a nil check causing a panic; update the case in the filtering function
to first check if model.MaxTokens == nil and, if so, set matchFilter = false and
populate resp.Code and resp.Message (e.g., explain max_tokens is missing),
otherwise safely compare *model.MaxTokens to maxVal and keep the existing logic
that sets matchFilter = false and resp fields when the value is too small;
ensure you reference model.MaxTokens, matchFilter, resp.Code and resp.Message
when making the changes.

---

Nitpick comments:
In `@internal/entity/models/model.go`:
- Around line 428-436: The model serialization here always includes "max_tokens"
even if nil; update the loop in the function that builds modelList to match
ListAllModels' pattern by only adding "max_tokens" when model.MaxTokens != nil
and storing *model.MaxTokens (dereferenced) instead of the pointer. Locate the
loop over provider.Models (where modelData is created) and change the map
construction so "max_tokens" is conditionally added when non-nil, keeping "name"
and "model_types" unchanged.
- Around line 296-300: The code reads a hardcoded "conf/all_models.json" via
os.ReadFile which ignores the function's dirPath parameter; change the file
resolution to derive the config path from dirPath (or accept a configurable
path) before calling os.ReadFile so the function uses filepath.Join(dirPath,
"conf", "all_models.json") or a passed-in filename; update the read call that
assigns to data and err (the os.ReadFile usage) to use the derived/configurable
path and adjust any callers if you add a parameter.

In `@internal/entity/models/stepfun.go`:
- Line 371: Pre-allocate the slice capacity for models since len(data) is known:
change the allocation of models (type ListModelResponse) to reserve capacity
using make with a third argument (e.g., make([]ListModelResponse, 0, len(data)))
or allocate directly with length and fill by index; update places that append to
models accordingly to avoid repeated reallocations when iterating over data.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 17a9b849-cb1b-4387-bfbf-0aa9cfc34e0d

📥 Commits

Reviewing files that changed from the base of the PR and between c586292 and 8b447c3.

📒 Files selected for processing (68)
  • internal/dao/database.go
  • internal/entity/models/302ai.go
  • internal/entity/models/aliyun.go
  • internal/entity/models/anthropic.go
  • internal/entity/models/astraflow.go
  • internal/entity/models/avian.go
  • internal/entity/models/azure_openai.go
  • internal/entity/models/baichuan.go
  • internal/entity/models/baidu.go
  • internal/entity/models/bedrock.go
  • internal/entity/models/builtin.go
  • internal/entity/models/cohere.go
  • internal/entity/models/cometapi.go
  • internal/entity/models/deepinfra.go
  • internal/entity/models/deepseek.go
  • internal/entity/models/dummy.go
  • internal/entity/models/fishaudio.go
  • internal/entity/models/futurmix.go
  • internal/entity/models/gitee.go
  • internal/entity/models/google.go
  • internal/entity/models/gpustack.go
  • internal/entity/models/groq.go
  • internal/entity/models/huaweicloud.go
  • internal/entity/models/huggingface.go
  • internal/entity/models/hunyuan.go
  • internal/entity/models/jiekouai.go
  • internal/entity/models/jina.go
  • internal/entity/models/lmstudio.go
  • internal/entity/models/localai.go
  • internal/entity/models/longcat.go
  • internal/entity/models/mineru.go
  • internal/entity/models/mineru_local.go
  • internal/entity/models/minimax.go
  • internal/entity/models/mistral.go
  • internal/entity/models/model.go
  • internal/entity/models/model_test.go
  • internal/entity/models/modelscope.go
  • internal/entity/models/moonshot.go
  • internal/entity/models/n1n.go
  • internal/entity/models/novita.go
  • internal/entity/models/nvidia.go
  • internal/entity/models/ollama.go
  • internal/entity/models/openai.go
  • internal/entity/models/openrouter.go
  • internal/entity/models/orcarouter.go
  • internal/entity/models/paddleocr.go
  • internal/entity/models/paddleocr_local.go
  • internal/entity/models/perplexity.go
  • internal/entity/models/ppio.go
  • internal/entity/models/qiniu.go
  • internal/entity/models/replicate.go
  • internal/entity/models/siliconflow.go
  • internal/entity/models/stepfun.go
  • internal/entity/models/togetherai.go
  • internal/entity/models/tokenhub.go
  • internal/entity/models/tokenpony.go
  • internal/entity/models/types.go
  • internal/entity/models/upstage.go
  • internal/entity/models/vllm.go
  • internal/entity/models/volcengine.go
  • internal/entity/models/voyage.go
  • internal/entity/models/xai.go
  • internal/entity/models/xiaomi.go
  • internal/entity/models/xinference.go
  • internal/entity/models/xunfei.go
  • internal/entity/models/zhipu-ai.go
  • internal/handler/providers.go
  • internal/service/model_service.go

Comment on lines +798 to 805
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["id"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{
Name: modelName,
})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Unchecked type assertions can cause runtime panics.

Lines 799-801 contain unchecked type assertions that will panic if the API response structure differs from expectations (e.g., missing data field, non-object entries, or missing/non-string id). Other drivers in this PR (astraflow, azure_openai) handle this safely with ok checks.

🐛 Proposed fix to add safe type assertions
 // convert result["data"] to []map[string]interface{}
 	models := make([]ListModelResponse, 0)
-	for _, model := range result["data"].([]interface{}) {
-		modelMap := model.(map[string]interface{})
-		modelName := modelMap["id"].(string)
+	data, ok := result["data"].([]interface{})
+	if !ok {
+		return nil, fmt.Errorf("invalid models list format")
+	}
+	for _, model := range data {
+		modelMap, ok := model.(map[string]interface{})
+		if !ok {
+			continue
+		}
+		modelName, ok := modelMap["id"].(string)
+		if !ok || modelName == "" {
+			continue
+		}
 		models = append(models, ListModelResponse{
 			Name: modelName,
 		})
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/baidu.go` around lines 798 - 805, The loop over
result["data"] uses unchecked type assertions and can panic; update the code
that builds the models slice (the block creating models :=
make([]ListModelResponse, 0) and iterating over result["data"]) to safely assert
types: first check that result["data"] exists and is a []interface{} (with an ok
check), then for each entry assert it is a map[string]interface{} and safely
extract "id" as a string (with ok checks) before appending a
ListModelResponse{Name: modelName}; if any check fails, skip that entry (or
handle gracefully) so the function (in baidu.go) never panics on malformed API
responses.

Comment on lines 903 to 920
for _, model := range modelList.Models {
modelName := model.ID
var modelResponse ListModelResponse
pm := GetProviderManager()
modelEntity := pm.GetModelByNameOrAlias(modelName)
if model.OwnedBy != "" {
modelName = model.ID + "@" + model.OwnedBy
}
models = append(models, modelName)
modelResponse.Name = modelName
if modelEntity != nil {
modelResponse.Dimension = modelEntity.Dimension
modelResponse.MaxTokens = modelEntity.MaxTokens
modelResponse.ModelTypes = modelEntity.ModelTypes
modelResponse.Thinking = modelEntity.Thinking
}

models = append(models, modelResponse)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix metadata lookup timing: qualify model name before lookup.

The provider lookup at line 907 uses the base model.ID, but the final modelResponse.Name includes the @OwnedBy suffix (lines 908-910). If the provider manager indexes models by their fully-qualified names (e.g., "DeepSeek-V4-Flash@deepseek-ai"), this lookup will fail to retrieve metadata for models that have an OwnedBy field set.

As a result, Dimension, MaxTokens, ModelTypes, and Thinking will remain nil for qualified model names, even when metadata exists in the provider manager under the qualified key.

🔧 Proposed fix
 	for _, model := range modelList.Models {
 		modelName := model.ID
+		if model.OwnedBy != "" {
+			modelName = model.ID + "@" + model.OwnedBy
+		}
 		var modelResponse ListModelResponse
 		pm := GetProviderManager()
 		modelEntity := pm.GetModelByNameOrAlias(modelName)
-		if model.OwnedBy != "" {
-			modelName = model.ID + "@" + model.OwnedBy
-		}
 		modelResponse.Name = modelName
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/gitee.go` around lines 903 - 920, The lookup uses
model.ID when calling GetProviderManager().GetModelByNameOrAlias but the
canonical name used later includes the OwnedBy suffix; update the code to build
the fully-qualified modelName (using model.ID and model.OwnedBy) before calling
GetModelByNameOrAlias so the provider manager can find metadata for names like
"ModelID@OwnedBy"; then populate modelResponse from modelEntity as before
(fields: Dimension, MaxTokens, ModelTypes, Thinking) and append to models.
Ensure you still set modelResponse.Name to the final qualified name (model.ID +
"@" + model.OwnedBy when OwnedBy != "").

Comment on lines +514 to 519
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["id"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard type assertions to prevent panics.

Lines 515-517 use unchecked type assertions that will panic if the API response shape is unexpected. If result["data"] is not []interface{}, or if an element is not map[string]interface{}, or if "id" is not a string, the driver will crash.

🛡️ Proposed fix
 	models := make([]ListModelResponse, 0)
-	for _, model := range result["data"].([]interface{}) {
-		modelMap := model.(map[string]interface{})
-		modelName := modelMap["id"].(string)
+	data, ok := result["data"].([]interface{})
+	if !ok {
+		return nil, fmt.Errorf("invalid data format in models list response")
+	}
+	for _, model := range data {
+		modelMap, ok := model.(map[string]interface{})
+		if !ok {
+			continue
+		}
+		modelName, ok := modelMap["id"].(string)
+		if !ok || modelName == "" {
+			continue
+		}
 		models = append(models, ListModelResponse{Name: modelName})
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["id"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}
models := make([]ListModelResponse, 0)
data, ok := result["data"].([]interface{})
if !ok {
return nil, fmt.Errorf("invalid data format in models list response")
}
for _, model := range data {
modelMap, ok := model.(map[string]interface{})
if !ok {
continue
}
modelName, ok := modelMap["id"].(string)
if !ok || modelName == "" {
continue
}
models = append(models, ListModelResponse{Name: modelName})
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/huggingface.go` around lines 514 - 519, The loop that
builds []ListModelResponse uses unchecked type assertions on result["data"],
each element, and the "id" field which can panic; update the code that iterates
over result (used when building models) to first check that result["data"] is a
[]interface{} (use a type assertion with ok), then for each element assert it's
a map[string]interface{} with ok, and that modelMap["id"] is a string before
appending to models (skip or continue on invalid entries and optionally log the
unexpected shapes); modify the block that creates models and references
modelMap/modelName/ListModelResponse accordingly to use these guarded checks.

Comment on lines +358 to 363
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["name"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard type assertions to prevent panics.

Lines 359-361 use unchecked type assertions that will panic if the API response shape is unexpected. If result["data"] is not []interface{}, or if an element is not map[string]interface{}, or if "name" is not a string, the driver will crash.

🛡️ Proposed fix
 	models := make([]ListModelResponse, 0)
-	for _, model := range result["data"].([]interface{}) {
-		modelMap := model.(map[string]interface{})
-		modelName := modelMap["name"].(string)
+	data, ok := result["data"].([]interface{})
+	if !ok {
+		return nil, fmt.Errorf("invalid data format in models list response")
+	}
+	for _, model := range data {
+		modelMap, ok := model.(map[string]interface{})
+		if !ok {
+			continue
+		}
+		modelName, ok := modelMap["name"].(string)
+		if !ok || modelName == "" {
+			continue
+		}
 		models = append(models, ListModelResponse{Name: modelName})
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["name"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}
models := make([]ListModelResponse, 0)
data, ok := result["data"].([]interface{})
if !ok {
return nil, fmt.Errorf("invalid data format in models list response")
}
for _, model := range data {
modelMap, ok := model.(map[string]interface{})
if !ok {
continue
}
modelName, ok := modelMap["name"].(string)
if !ok || modelName == "" {
continue
}
models = append(models, ListModelResponse{Name: modelName})
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/jina.go` around lines 358 - 363, The loop over
result["data"] uses unchecked type assertions and can panic; update the code
that builds models (the slice of ListModelResponse) to safely type-assert
result["data"] to []interface{} (check the ok boolean), iterate only if
successful, for each element assert it is map[string]interface{} (with an ok
check), then extract "name" as a string with an ok check before creating a
ListModelResponse; on any failed assertion skip the item and optionally log a
warning (do not panic) so the driver remains resilient.

Comment on lines +564 to 569
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["id"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard type assertions to prevent panics.

Lines 565-567 use unchecked type assertions that will panic if the API response shape is unexpected. If result["data"] is not []interface{}, or if an element is not map[string]interface{}, or if "id" is not a string, the driver will crash.

🛡️ Proposed fix
 	models := make([]ListModelResponse, 0)
-	for _, model := range result["data"].([]interface{}) {
-		modelMap := model.(map[string]interface{})
-		modelName := modelMap["id"].(string)
+	data, ok := result["data"].([]interface{})
+	if !ok {
+		return nil, fmt.Errorf("invalid data format in models list response")
+	}
+	for _, model := range data {
+		modelMap, ok := model.(map[string]interface{})
+		if !ok {
+			continue
+		}
+		modelName, ok := modelMap["id"].(string)
+		if !ok || modelName == "" {
+			continue
+		}
 		models = append(models, ListModelResponse{Name: modelName})
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["id"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}
models := make([]ListModelResponse, 0)
data, ok := result["data"].([]interface{})
if !ok {
return nil, fmt.Errorf("invalid data format in models list response")
}
for _, model := range data {
modelMap, ok := model.(map[string]interface{})
if !ok {
continue
}
modelName, ok := modelMap["id"].(string)
if !ok || modelName == "" {
continue
}
models = append(models, ListModelResponse{Name: modelName})
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/lmstudio.go` around lines 564 - 569, The loop building
models from result uses unchecked type assertions and can panic; update the code
that constructs the []ListModelResponse from result to first verify
result["data"] is a []interface{} (using the comma-ok/type switch), then for
each element assert it is a map[string]interface{} and that map["id"] is a
string (using comma-ok), skipping or logging entries that fail validation
instead of panicking; keep the output type as []ListModelResponse and only
append valid Name values to models to preserve existing behavior.

Comment on lines 519 to 523
for _, model := range result["models"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["name"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Unsafe type assertions can panic on unexpected API responses.

Lines 519-521 use direct type assertions without checking the ok return value. If the Ollama API returns an unexpected format (e.g., models is nil, or entries have different structure), this will cause a runtime panic.

Other drivers in this PR (novita, nvidia, openai) correctly use safe type assertions with ok checks.

🛡️ Proposed fix using safe type assertions
 	// convert result["data"] to []map[string]interface{}
 	models := make([]ListModelResponse, 0)
-	for _, model := range result["models"].([]interface{}) {
-		modelMap := model.(map[string]interface{})
-		modelName := modelMap["name"].(string)
+	modelsList, ok := result["models"].([]interface{})
+	if !ok {
+		return nil, fmt.Errorf("invalid models list format")
+	}
+	for _, model := range modelsList {
+		modelMap, ok := model.(map[string]interface{})
+		if !ok {
+			continue
+		}
+		modelName, ok := modelMap["name"].(string)
+		if !ok {
+			continue
+		}
 		models = append(models, ListModelResponse{Name: modelName})
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for _, model := range result["models"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["name"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}
// convert result["data"] to []map[string]interface{}
models := make([]ListModelResponse, 0)
modelsList, ok := result["models"].([]interface{})
if !ok {
return nil, fmt.Errorf("invalid models list format")
}
for _, model := range modelsList {
modelMap, ok := model.(map[string]interface{})
if !ok {
continue
}
modelName, ok := modelMap["name"].(string)
if !ok {
continue
}
models = append(models, ListModelResponse{Name: modelName})
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/ollama.go` around lines 519 - 523, The loop over
result["models"] in ollama.go uses unsafe type assertions and can panic; update
the code that iterates over result["models"] to use safe type assertions (check
ok when casting result["models"] to []interface{} and when casting each model to
map[string]interface{} and the "name" field to string), skip entries that fail
casts instead of panicking, and append valid names to ListModelResponse{Name:
...}; ensure you reference the existing variables/result map and the
ListModelResponse type so behavior stays consistent with other drivers (novita,
nvidia, openai).

Comment on lines +795 to 800
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["id"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Unsafe type assertions can cause runtime panic.

Lines 796-798 perform type assertions without checking the ok result. If the OpenRouter API returns an unexpected response format, these will panic at runtime.

🛡️ Suggested fix to add safety checks
 	// convert result["data"] to []map[string]interface{}
 	models := make([]ListModelResponse, 0)
-	for _, model := range result["data"].([]interface{}) {
-		modelMap := model.(map[string]interface{})
-		modelName := modelMap["id"].(string)
+	data, ok := result["data"].([]interface{})
+	if !ok {
+		return nil, fmt.Errorf("invalid response format: data field is not an array")
+	}
+	for _, model := range data {
+		modelMap, ok := model.(map[string]interface{})
+		if !ok {
+			continue
+		}
+		modelName, ok := modelMap["id"].(string)
+		if !ok || modelName == "" {
+			continue
+		}
 		models = append(models, ListModelResponse{Name: modelName})
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/openrouter.go` around lines 795 - 800, The loop
building models from result["data"] uses unchecked type assertions and can
panic; update the code that iterates over result["data"] to safely assert types
(check ok values) for the top-level slice, each element being a
map[string]interface{}, and the "id" field being a string before using them
(symbols: result, models, ListModelResponse, modelMap, modelName); skip or log
invalid entries instead of asserting, and only append ListModelResponse{Name:
modelName} when all assertions succeed.

Comment on lines +467 to 472
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["id"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Unsafe type assertions can cause runtime panic.

Lines 468-470 perform type assertions without checking the ok result. If the OrcaRouter API returns an unexpected response format, these will panic at runtime.

🛡️ Suggested fix to add safety checks
 	// convert result["data"] to []map[string]interface{}
 	models := make([]ListModelResponse, 0)
-	for _, model := range result["data"].([]interface{}) {
-		modelMap := model.(map[string]interface{})
-		modelName := modelMap["id"].(string)
+	data, ok := result["data"].([]interface{})
+	if !ok {
+		return nil, fmt.Errorf("invalid response format: data field is not an array")
+	}
+	for _, model := range data {
+		modelMap, ok := model.(map[string]interface{})
+		if !ok {
+			continue
+		}
+		modelName, ok := modelMap["id"].(string)
+		if !ok || modelName == "" {
+			continue
+		}
 		models = append(models, ListModelResponse{Name: modelName})
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/orcarouter.go` around lines 467 - 472, The loop
blindly type-asserts result["data"] and each model to concrete types which can
panic; change the parsing in the ListModelResponse construction to perform safe
type checks (use a type assertion with the "ok" idiom or a type switch) for
result["data"] to ensure it's a []interface{}, for each model to ensure it's a
map[string]interface{}, and for the "id" field to ensure it's a string, skip or
log entries that fail validation instead of asserting; update the block that
builds models (references: result, models, modelMap, modelName,
ListModelResponse) to only append when all checks succeed.

Comment on lines +439 to +443
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["id"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard ListModels response parsing against panics.

These hard assertions will panic if the upstream payload shape changes (or returns an error object with HTTP 200). Convert them to checked assertions and return an error instead.

Proposed fix
-	models := make([]ListModelResponse, 0)
-	for _, model := range result["data"].([]interface{}) {
-		modelMap := model.(map[string]interface{})
-		modelName := modelMap["id"].(string)
-		models = append(models, ListModelResponse{Name: modelName})
-	}
+	rawData, ok := result["data"].([]interface{})
+	if !ok {
+		return nil, fmt.Errorf("invalid models response: missing/invalid data field")
+	}
+	models := make([]ListModelResponse, 0, len(rawData))
+	for _, item := range rawData {
+		modelMap, ok := item.(map[string]interface{})
+		if !ok {
+			return nil, fmt.Errorf("invalid models response: invalid model item")
+		}
+		modelName, ok := modelMap["id"].(string)
+		if !ok || strings.TrimSpace(modelName) == "" {
+			continue
+		}
+		models = append(models, ListModelResponse{Name: modelName})
+	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
models := make([]ListModelResponse, 0)
for _, model := range result["data"].([]interface{}) {
modelMap := model.(map[string]interface{})
modelName := modelMap["id"].(string)
models = append(models, modelName)
models = append(models, ListModelResponse{Name: modelName})
rawData, ok := result["data"].([]interface{})
if !ok {
return nil, fmt.Errorf("invalid models response: missing/invalid data field")
}
models := make([]ListModelResponse, 0, len(rawData))
for _, item := range rawData {
modelMap, ok := item.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("invalid models response: invalid model item")
}
modelName, ok := modelMap["id"].(string)
if !ok || strings.TrimSpace(modelName) == "" {
continue
}
models = append(models, ListModelResponse{Name: modelName})
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/xunfei.go` around lines 439 - 443, In ListModels,
avoid unchecked type assertions on result["data"] and its elements (currently
producing modelMap := model.(map[string]interface{}) and
modelMap["id"].(string)); instead validate types with comma-ok checks and return
a descriptive error if the payload shape is unexpected (e.g., ensure
result["data"] exists and is []interface{}, each item is map[string]interface{},
and "id" is a string) before appending to the models slice (ListModelResponse);
update error handling to propagate a clear error rather than allowing a panic.

Comment on lines +247 to +257
var result []map[string]interface{}
for _, model := range modelList {
result = append(result, map[string]interface{}{
"name": model.Name,
"dimension": model.Dimension,
"max_tokens": model.MaxTokens,
"model_types": model.ModelTypes,
"thinking": model.Thinking,
})
}
return result, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Return an empty array (not null) for empty supported-model results.

When no models are returned, this stays nil and is serialized as null. Initialize the slice to preserve a stable array response contract.

Proposed fix
-	var result []map[string]interface{}
+	result := make([]map[string]interface{}, 0, len(modelList))
 	for _, model := range modelList {
 		result = append(result, map[string]interface{}{
 			"name":        model.Name,
 			"dimension":   model.Dimension,
 			"max_tokens":  model.MaxTokens,
 			"model_types": model.ModelTypes,
 			"thinking":    model.Thinking,
 		})
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var result []map[string]interface{}
for _, model := range modelList {
result = append(result, map[string]interface{}{
"name": model.Name,
"dimension": model.Dimension,
"max_tokens": model.MaxTokens,
"model_types": model.ModelTypes,
"thinking": model.Thinking,
})
}
return result, nil
result := make([]map[string]interface{}, 0, len(modelList))
for _, model := range modelList {
result = append(result, map[string]interface{}{
"name": model.Name,
"dimension": model.Dimension,
"max_tokens": model.MaxTokens,
"model_types": model.ModelTypes,
"thinking": model.Thinking,
})
}
return result, nil
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/service/model_service.go` around lines 247 - 257, The slice result
is left nil when modelList is empty, causing JSON serialization to emit null;
initialize result as an empty slice (e.g. result :=
make([]map[string]interface{}, 0)) before the loop that iterates modelList so
you always return an empty array instead of nil from the function that builds
maps from model.Name, model.Dimension, model.MaxTokens, model.ModelTypes,
model.Thinking.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (1ab51a2) to head (8b447c3).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15845   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit 719ce15 into infiniflow:main Jun 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant