{"record":{"id":"628e447345fa468f","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-unmarshal-response-from-s-w-628e44","errorCode":null,"errorMessage":"cannot unmarshal response from %s: %w","messagePattern":"cannot unmarshal response from (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/promscrape/discovery/ovhcloud/vps.go","lineNumber":125,"sourceCode":"\t}\n\treturn ms, nil\n}\n\n// getVPSDetails get properties of a VPS.\n// Also see: https://eu.api.ovh.com/console/#/vps/%7BserviceName%7D~GET\nfunc getVPSDetails(cfg *apiConfig, vpsName string) (*virtualPrivateServer, error) {\n\t// get properties.\n\treqPath := path.Join(\"/vps\", url.QueryEscape(vpsName))\n\tresp, err := cfg.client.GetAPIResponseWithReqParams(reqPath, func(request *http.Request) {\n\t\trequest.Header, _ = getAuthHeaders(cfg, request.Header, cfg.client.APIServer(), reqPath)\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot process %s: %w\", reqPath, err)\n\t}\n\n\tvar vpsDetails virtualPrivateServer\n\tif err = json.Unmarshal(resp, &vpsDetails); err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot unmarshal response from %s: %w\", reqPath, err)\n\t}\n\n\t// get IPs for this vps.\n\t// e.g. [\"139.99.154.111\",\"2402:1f00:8100:401::bb6\"]\n\t// Also see: https://eu.api.ovh.com/console/#/vps/%7BserviceName%7D/ips~GET\n\treqPath = path.Join(reqPath, \"ips\")\n\tresp, err = cfg.client.GetAPIResponseWithReqParams(reqPath, func(request *http.Request) {\n\t\trequest.Header, _ = getAuthHeaders(cfg, request.Header, cfg.client.APIServer(), reqPath)\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot process %s: %w\", reqPath, err)\n\t}\n\n\tvar ips []string\n\tif err = json.Unmarshal(resp, &ips); err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot unmarshal response from %s: %w\", reqPath, err)\n\t}\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/promscrape/discovery/ovhcloud/vps.go#L107-L143","documentation":"Returned by getVPSDetails when the JSON body from GET /vps/{serviceName} cannot be unmarshaled into the virtualPrivateServer struct. The API responded, but with data not matching the expected schema (fields/types differ). Cause is wrapped with %w.","triggerScenarios":"json.Unmarshal(resp, &vpsDetails) fails: body is an OVH error object, HTML from a proxy, or a schema mismatch (e.g. a field type changed in the OVH API that no longer matches the struct).","commonSituations":"OVH API schema evolution breaking the struct; error payload returned with success status; proxy/WAF injecting HTML; truncated responses on flaky connections.","solutions":["Capture and inspect the raw response body to see the actual payload","Confirm the request is hitting the official OVH endpoint (not a proxy returning errors as HTML)","Check the library version against recent OVH /vps API schema changes; upgrade the library if the API evolved","Retry after confirming OVH API health if it was a transient malformed response"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// verify payload shape before unmarshal\nif len(resp) > 0 && resp[0] != '{' {\n    return fmt.Errorf(\"unexpected /vps payload, want JSON object: %q\", resp[:min(200, len(resp))])\n}","typeGuard":"func looksLikeVPSObject(b []byte) bool {\n    var m map[string]json.RawMessage\n    return json.Unmarshal(b, &m) == nil && len(m) > 0\n}","tryCatchPattern":"// log body on schema mismatch\nif err := json.Unmarshal(resp, &vpsDetails); err != nil {\n    log.Printf(\"vps schema mismatch: %v; body=%s\", err, string(resp))\n    return nil, err\n}","preventionTips":["Upgrade the library when OVH changes the /vps schema","Log raw bodies on unmarshal failure","Keep API traffic free of HTML-injecting proxies","Test against the OVH API console to compare payload shape"],"tags":["json","unmarshal","schema","promscrape","ovhcloud"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}