{"record":{"id":"8f2430846a29a2bd","repo":"prometheus/node_exporter","slug":"couldn-t-get-ioppowersourceslist-w","errorCode":null,"errorMessage":"couldn't get IOPPowerSourcesList: %w","messagePattern":"couldn't get IOPPowerSourcesList: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/powersupplyclass_darwin.go","lineNumber":193,"sourceCode":"    free(ps->InternalFailure);\n    free(ps->IsPresent);\n\n    free(ps);\n}\n*/\nimport \"C\"\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\n\t\"github.com/prometheus/client_golang/prometheus\"\n)\n\nfunc (c *powerSupplyClassCollector) Update(ch chan<- prometheus.Metric) error {\n\tpsList, err := getPowerSourceList()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get IOPPowerSourcesList: %w\", err)\n\t}\n\n\tfor _, info := range psList {\n\t\tlabels := getPowerSourceDescriptorLabels(info)\n\t\tpowerSupplyName := labels[\"power_supply\"]\n\n\t\tif c.ignoredPattern.MatchString(powerSupplyName) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor name, value := range getPowerSourceDescriptorMap(info) {\n\t\t\tif value == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\tprometheus.NewDesc(\n\t\t\t\t\tprometheus.BuildFQName(namespace, c.subsystem, name),","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/powersupplyclass_darwin.go#L175-L211","documentation":"The Darwin power supply collector's Update calls getPowerSourceList(), which wraps IOKit's IOPSCopyPowerSourcesInfo/IOPSCopyPowerSourcesList. When that IOKit call fails, the error is wrapped as \"couldn't get IOPPowerSourcesList\". This means the collector could not enumerate the machine's power sources (battery/AC) via IOKit, so no power metrics can be reported for this scrape.","triggerScenarios":"Update -> getPowerSourceList returning an error, i.e. IOPSCopyPowerSourcesList failing or returning nil on macOS — typically when the process lacks entitlement/sandbox access to IOKit power services or IOKit returns no power sources handle.","commonSituations":"Running node_exporter inside a sandbox/container on macOS where IOKit power APIs are restricted; running in CI VMs without battery/power-source services; IOKit returning NULL under unusual system states.","solutions":["Run the collector outside sandbox/container restrictions so it can talk to IOKit power services (host access, not virtualized).","Check that macOS power management is functioning (pmset -g batt works for the same user).","If the host has no queryable power sources, disable the powersupply collector instead of treating the scrape as failed."],"exampleFix":"// before\nnode_exporter --collector.powersupply  # inside a container\n// after\nnode_exporter --collector.powersupply  # run directly on the macOS host","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Update already returns the wrapped error; treat it as a failed scrape.\nif err := coll.Update(ch); err != nil {\n\tif isPowerSourceUnavailable(err) {\n\t\tlogger.Warn(\"power sources unavailable; skipping powersupply collection\", \"err\", err)\n\t\treturn nil\n\t}\n\treturn err\n}","preventionTips":["Run node_exporter directly on the macOS host, not inside containers or sandboxes.","Smoke-test IOKit access with `pmset -g batt` under the same user before deploying.","Disable the powersupply collector on hosts known to have no queryable power sources."],"tags":["go","macos","iokit","powersupply","node-exporter"],"backgroundTag":"api-request-failed","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}