{"record":{"id":"d293f988fd3b43a8","repo":"mickael-kerjean/filestash","slug":"api-returned-status-d-s","errorCode":null,"errorMessage":"API returned status %d: %s","messagePattern":"API returned status (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/plugin/plg_backend_syncthing/index_helper.go","lineNumber":50,"sourceCode":"\t}\n\n\treq, err := http.NewRequest(\"GET\", apiURL, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"X-Api-Key\", s.apiKey)\n\tresp, err := s.client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"API returned status %d: %s\", resp.StatusCode, string(body))\n\t}\n\treturn body, nil\n}\n\nfunc (s *Syncthing) fetchFolders() ([]SyncFolder, error) {\n\tdata, err := s.makeAPICall(\"/rest/config\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar config struct {\n\t\tFolders []struct {\n\t\t\tID    string `json:\"id\"`\n\t\t\tLabel string `json:\"label\"`\n\t\t\tPath  string `json:\"path\"`\n\t\t} `json:\"folders\"`\n\t}\n\tif err := json.Unmarshal(data, &config); err != nil {\n\t\treturn nil, err","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/mickael-kerjean/filestash/blob/78f756eb94ef383f1f1cd4bc3077a43a4d088ff0/server/plugin/plg_backend_syncthing/index_helper.go#L32-L68","documentation":"Returned by Syncthing.makeAPICall when the Syncthing REST API (e.g. /rest/config) responds with a non-200 status. The message carries the status code and raw response body, covering auth failures (bad X-Api-Key → 403), wrong URL prefix, or Syncthing errors; callers fetchFolders and listDirectory then fail.","triggerScenarios":"Thrown at server/plugin/plg_backend_syncthing/index_helper.go:50 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the configured API key matches Syncthing's GUI/API key and that X-Api-Key is accepted (403 vs 404 distinction)","Check the Syncthing URL/host/port, including any reverse-proxy path prefix","Read the response body in the error — Syncthing includes the reason there","Confirm Syncthing is running and the REST API is enabled and reachable from the plugin"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f756eb94ef383f1f1cd4bc3077a43a4d088ff0","analyzedAt":"2026-09-06T11:52:48.712Z","contentChangedAt":"2026-09-06T11:52:48.712Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}