{"record":{"id":"3dfb167ccb5173e4","repo":"router-for-me/CLIProxyAPI","slug":"home-models-payload-has-no-sections","errorCode":null,"errorMessage":"home models payload has no sections","messagePattern":"home models payload has no sections","errorType":"http","errorClass":null,"httpStatus":502,"severity":"error","filePath":"internal/api/server_routes.go","lineNumber":978,"sourceCode":"\t}\n\tvar top map[string]json.RawMessage\n\tif errUnmarshal := json.Unmarshal(raw, &top); errUnmarshal != nil {\n\t\treturn nil, false\n\t}\n\treturn top, true\n}\n\nfunc decodeHomeModels(raw []byte) ([]homeModelEntry, error) {\n\tif len(raw) == 0 {\n\t\treturn nil, fmt.Errorf(\"home models payload is empty\")\n\t}\n\n\tvar bySection map[string][]map[string]any\n\tif err := json.Unmarshal(raw, &bySection); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse home models payload: %w\", err)\n\t}\n\tif len(bySection) == 0 {\n\t\treturn nil, fmt.Errorf(\"home models payload has no sections\")\n\t}\n\n\tseen := make(map[string]struct{})\n\tout := make([]homeModelEntry, 0, 256)\n\tfor _, models := range bySection {\n\t\tfor _, model := range models {\n\t\t\tid, _ := model[\"id\"].(string)\n\t\t\tid = strings.TrimSpace(id)\n\t\t\tif id == \"\" {\n\t\t\t\tname, _ := model[\"name\"].(string)\n\t\t\t\tname = strings.TrimSpace(name)\n\t\t\t\tid = strings.TrimPrefix(name, \"models/\")\n\t\t\t}\n\t\t\tif id == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif _, ok := seen[id]; ok {\n\t\t\t\tcontinue","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/api/server_routes.go#L960-L996","documentation":"The home models payload parsed as valid JSON of the expected map shape, but the map contains no sections (len(bySection) == 0, i.e. '{}'). Each top-level key is expected to be a section holding an array of model objects; an empty object means the structure is present but empty.","triggerScenarios":"Upstream returned literal '{}' for the models payload; a filtering layer removed all sections before decode; a config-driven home models file was created empty.","commonSituations":"Region-restricted accounts getting an empty catalog; an upstream A/B change; a user-edited local models file reduced to '{}'.","solutions":["Fetch the payload manually (curl with the same auth) and inspect the top-level keys","If the account genuinely has no models, surface a clearer message about an empty catalog rather than a parse error","If a local file is the source, restore or repopulate it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"sections, ok := topLevelObjectKeys(raw)\nif ok && len(sections) == 0 {\n\t// empty catalog: skip decode instead of erroring\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch and inspect the payload manually when the catalog errors","Distinguish 'empty catalog' from 'broken payload' in handling"],"tags":["json","models-list","validation"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}