{"record":{"id":"e4793f890f7194af","repo":"router-for-me/CLIProxyAPI","slug":"home-models-payload-contains-no-models","errorCode":null,"errorMessage":"home models payload contains no models","messagePattern":"home models payload contains no models","errorType":"http","errorClass":null,"httpStatus":502,"severity":"error","filePath":"internal/api/server_routes.go","lineNumber":1022,"sourceCode":"\t\t\tif displayName == \"\" {\n\t\t\t\tdisplayName, _ = model[\"displayName\"].(string)\n\t\t\t\tdisplayName = strings.TrimSpace(displayName)\n\t\t\t}\n\n\t\t\tout = append(out, homeModelEntry{\n\t\t\t\tid:                  id,\n\t\t\t\tcreated:             homeModelInt64Value(model, \"created\"),\n\t\t\t\townedBy:             ownedBy,\n\t\t\t\tdisplayName:         displayName,\n\t\t\t\tcontextLength:       int(homeModelInt64Value(model, \"context_length\", \"contextLength\", \"inputTokenLimit\", \"max_input_tokens\")),\n\t\t\t\tmaxCompletionTokens: int(homeModelInt64Value(model, \"max_completion_tokens\", \"maxCompletionTokens\", \"outputTokenLimit\", \"max_tokens\")),\n\t\t\t})\n\t\t}\n\t}\n\n\tsort.Slice(out, func(i, j int) bool { return out[i].id < out[j].id })\n\tif len(out) == 0 {\n\t\treturn nil, fmt.Errorf(\"home models payload contains no models\")\n\t}\n\treturn out, nil\n}\n\nfunc homeModelInt64Value(model map[string]any, keys ...string) int64 {\n\tfor _, key := range keys {\n\t\tswitch value := model[key].(type) {\n\t\tcase float64:\n\t\t\treturn int64(value)\n\t\tcase int64:\n\t\t\treturn value\n\t\tcase int:\n\t\t\treturn int64(value)\n\t\tcase json.Number:\n\t\t\tif n, errInt := value.Int64(); errInt == nil {\n\t\t\t\treturn n\n\t\t\t}\n\t\tcase string:","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/api/server_routes.go#L1004-L1040","documentation":"decodeHomeModels parsed one or more sections but ended with zero usable entries: every model object either lacked a non-empty 'id' (or a 'name' usable as fallback id) or was not a string. After sorting, len(out) == 0 triggers this error as a final sanity check.","triggerScenarios":"Sections exist but their arrays are empty; model objects use a renamed id field (e.g. 'model' or 'slug') so every id resolves to ''; entries are not JSON objects (e.g. arrays of strings).","commonSituations":"Upstream schema change renaming 'id'; a feed that returns section metadata objects instead of model lists.","solutions":["Dump one raw model object from the payload to check the id/name field names actually present","If the schema changed, update the field extraction in decodeHomeModels (id, name keys) to the new names","If sections legitimately contain no models, treat this as an empty catalog instead of an error"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"sample := firstModelObject(raw)\nif sample != nil && strField(sample, \"id\") == \"\" && strField(sample, \"name\") == \"\" {\n\t// schema drift: id field renamed — do not treat as model list\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Log one raw model object when zero entries are extracted","Watch upstream schema changes before they empty your catalog"],"tags":["json","models-list","schema-drift"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}