{"record":{"id":"15093b33679e4713","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-get-api-config-w-15093b","errorCode":null,"errorMessage":"cannot get API config: %w","messagePattern":"cannot get API config: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/promscrape/discovery/ovhcloud/ovhcloud.go","lineNumber":35,"sourceCode":"\n// SDConfig is the configuration for OVH Cloud service discovery.\ntype SDConfig struct {\n\tEndpoint          string           `yaml:\"endpoint\"`\n\tApplicationKey    string           `yaml:\"application_key\"`\n\tApplicationSecret *promauth.Secret `yaml:\"application_secret\"`\n\tConsumerKey       *promauth.Secret `yaml:\"consumer_key\"`\n\tService           string           `yaml:\"service\"`\n\n\tHTTPClientConfig  promauth.HTTPClientConfig  `yaml:\",inline\"`\n\tProxyURL          *proxy.URL                 `yaml:\"proxy_url,omitempty\"`\n\tProxyClientConfig promauth.ProxyClientConfig `yaml:\",inline\"`\n}\n\n// GetLabels returns labels for OVH Cloud according to service discover config.\nfunc (sdc *SDConfig) GetLabels(baseDir string) ([]*promutil.Labels, error) {\n\tcfg, err := getAPIConfig(sdc, baseDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot get API config: %w\", err)\n\t}\n\tswitch sdc.Service {\n\tcase \"dedicated_server\":\n\t\treturn getDedicatedServerLabels(cfg)\n\tcase \"vps\":\n\t\treturn getVPSLabels(cfg)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"skipping unexpected service=%q; only `dedicated_server` and `vps` are supported for now\", sdc.Service)\n\t}\n}\n\n// MustStop stops further usage for sdc.\nfunc (sdc *SDConfig) MustStop() {\n\tv := configMap.Delete(sdc)\n\tif v != nil {\n\t\tcfg := v.(*apiConfig)\n\t\tcfg.client.Stop()\n\t}","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/promscrape/discovery/ovhcloud/ovhcloud.go#L17-L53","documentation":"Returned by SDConfig.GetLabels when building the OVH Cloud API client configuration (getAPIConfig) fails. Typically the provided SD config is invalid (bad credentials format, unreadable file referenced in config) so no API calls can even be attempted. The underlying cause is wrapped with %w.","triggerScenarios":"getAPIConfig(sdc, baseDir) errors: missing/empty application_key, application_secret or consumer_key; invalid config fields; failure resolving paths relative to baseDir.","commonSituations":"Incomplete ovhcloud_sd_configs block in Prometheus/VictoriaMetrics scrape config; secrets placeholder not substituted (e.g. left as file: reference that doesn't resolve); typo in config keys.","solutions":["Inspect the wrapped cause in the error message to see which config field failed","Ensure application_key, application_secret and consumer_key are set and non-empty in the ovhcloud_sd_config","If using file-based secrets, confirm the referenced files exist and are readable relative to baseDir","Validate the whole scrape config with the config-check flag before reloading"],"exampleFix":"// before (missing secret)\novhcloud_sd_configs:\n  - service: dedicated_server\n    application_key: xxx\n// after\novhcloud_sd_configs:\n  - service: dedicated_server\n    application_key: xxx\n    application_secret: yyy\n    consumer_key: zzz","handlingStrategy":"validation","validationCode":"// pre-flight config check in Go\ncfg, err := getAPIConfig(sdc, baseDir)\nif err != nil {\n    return fmt.Errorf(\"invalid ovhcloud_sd_config: %w\", err)\n}\nif sdc.ApplicationKey == \"\" || sdc.ApplicationSecret == \"\" || sdc.ConsumerKey == \"\" {\n    return errors.New(\"ovhcloud_sd_config: all three credentials are required\")\n}","typeGuard":null,"tryCatchPattern":"// fail fast at config load, not per scrape\nif err := configCheck(); err != nil {\n    log.Fatalf(\"ovhcloud sd config invalid: %v\", err)\n}","preventionTips":["Run the config-check tool before every reload","Never leave credential fields empty or as unresolved placeholders","Verify secret files exist and are readable by the process","Keep SD configs in version control with schema linting"],"tags":["configuration","promscrape","ovhcloud","sd-config"],"backgroundTag":"invalid-configuration","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"}