siyuan-note/siyuan · warning
unexpected status code: %d
Error message
unexpected status code: %d
What it means
fetchModelsDevContextCatalog requires an HTTP 200 from the models.dev context-length catalog endpoint and fails with this error for any other status (404, 403, 429, 5xx, etc.). The status code is embedded so the caller knows exactly how the upstream request failed; refreshModelsDevContextCatalog then typically keeps any previously cached catalog.
Source
Thrown at kernel/agent/modelmeta_online.go:195
}
modelsDevState.catalog = catalog
modelsDevState.expiresAt = completedAt.Add(modelsDevCatalogCacheTTL)
modelsDevState.retryAt = time.Time{}
return nil
}
func fetchModelsDevContextCatalog(ctx context.Context) (*modelsDevContextCatalog, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, modelsDevEndpoint, nil)
if err != nil {
return nil, err
}
resp, err := httpclient.NewUserAgentClient(nil).Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
providers := map[string]modelsDevProvider{}
limited := io.LimitReader(resp.Body, modelsDevCatalogMaxBytes+1)
if err = json.NewDecoder(limited).Decode(&providers); err != nil {
return nil, err
}
if len(providers) == 0 {
return nil, errors.New("empty catalog")
}
catalog := &modelsDevContextCatalog{
providers: map[string]*modelsDevProviderCatalog{},
models: map[string]int{},
suffixes: map[string]int{},
}
ambiguousModels := map[string]bool{}
ambiguousSuffixes := map[string]bool{}View on GitHub (pinned to 8641553a1f)
Solutions
- Retry later — most non-200 cases (429/5xx) are transient upstream issues
- Check network/proxy configuration that may return error pages (403/502) instead of the catalog
- Verify the app version's catalog URL is still valid; update SiYuan if the endpoint moved
- Rely on the cached catalog if present; the failure only blocks refresh, not existing metadata
Defensive patterns
Strategy: fallback
Validate before calling
req, _ := http.NewRequest("GET", catalogURL, nil)
resp, err := httpclient.NewUserAgentClient(nil).Do(req)
if err == nil && resp.StatusCode != http.StatusOK { log.Printf("catalog refresh skipped, status %d; keeping cached catalog", resp.StatusCode) } Try / catch
if err != nil { log.Printf("context catalog refresh failed: %v; using cached catalog", err); return cachedCatalog, nil } Prevention
- Always keep the last successfully fetched catalog as a fallback
- Back off on 429 responses and honor Retry-After headers
- Pin an app version known to use a valid catalog URL
When it happens
Trigger: The GET to the models.dev catalog URL returns a non-200 status — endpoint moved/renamed, rate limited (429), blocked by auth/proxy (403), or upstream outage (5xx).
Common situations: models.dev is temporarily down or rate-limiting your IP; a corporate proxy intercepts the request; the catalog URL changed in a newer SiYuan version while an old build still requests the old path; intermittent 5xx during provider incidents.
Related errors
- empty catalog
- catalog has no providers with API endpoints and valid models
- read body failed: %s
- version request returned HTTP " + response.status
- authentication probe returned HTTP " + response.status
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/5ce7f78b1e245cdc.
Report an issue: GitHub.