{"record":{"id":"076a8792b435087b","repo":"JanDeDobbeleer/oh-my-posh","slug":"unable-to-parse-energy-full","errorCode":null,"errorMessage":"unable to parse energy_full","messagePattern":"unable to parse energy_full","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/runtime/battery/battery_linux.go","lineNumber":104,"sourceCode":"\t\tif isBattery(path) {\n\t\t\tbFiles = append(bFiles, path)\n\t\t}\n\t}\n\n\tif len(bFiles) == 0 {\n\t\treturn nil, &NoBatteryError{}\n\t}\n\n\treturn bFiles, nil\n}\n\nfunc getByPath(path string) (*battery, error) {\n\tb := &battery{}\n\tvar err error\n\n\tif b.Current, err = readFloat(path, \"energy_now\"); err == nil {\n\t\tif b.Full, err = readFloat(path, \"energy_full\"); err != nil {\n\t\t\treturn nil, errors.New(\"unable to parse energy_full\")\n\t\t}\n\t} else {\n\t\tcurrentDoesNotExist := os.IsNotExist(err)\n\t\tif b.Voltage, err = readFloat(path, \"voltage_now\"); err != nil {\n\t\t\treturn nil, errors.New(\"unable to parse voltage_now\")\n\t\t}\n\t\tb.Voltage /= 1000\n\t\tif currentDoesNotExist {\n\t\t\tif b.Current, err = readAmp(path, \"charge_now\", b.Voltage); err != nil {\n\t\t\t\treturn nil, errors.New(\"unable to parse charge_now\")\n\t\t\t}\n\t\t\tif b.Full, err = readAmp(path, \"charge_full\", b.Voltage); err != nil {\n\t\t\t\treturn nil, errors.New(\"unable to parse charge_full\")\n\t\t\t}\n\t\t} else {\n\t\t\tif b.Full, err = readFloat(path, \"energy_full\"); err != nil {\n\t\t\t\treturn nil, errors.New(\"unable to parse energy_full\")\n\t\t\t}","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/runtime/battery/battery_linux.go#L86-L122","documentation":"On Linux the battery is read from sysfs files under /sys/class/power_supply/<name>/. getByPath first tries the energy_* pair: if energy_now reads OK but energy_full cannot be parsed/read, the pair is inconsistent and this error aborts that battery's info.","triggerScenarios":"readFloat(path, \"energy_full\") fails after energy_now succeeded - i.e. energy_full is missing, unreadable (permissions), or contains a non-numeric value (e.g. empty because the driver hasn't computed full charge).","commonSituations":"A battery whose energy_full is empty at boot or during driver initialization; vendor firmware quirks exposing energy_now but not energy_full; reading a device directory (e.g. 'AC') that has partial files; container/VM with synthetic power_supply entries.","solutions":["Check the file manually: cat /sys/class/power_supply/*/energy_full - find the device with a broken value","Reboot or reload the battery kernel module so the driver repopulates energy_full","Update BIOS/firmware if the vendor reports a full-charge capacity of 0","In the theme, conditionally render the battery segment so a single bad sysfs node doesn't break the prompt"],"exampleFix":"// before\nif b.Current, err = readFloat(path, \"energy_now\"); err == nil {\n    if b.Full, err = readFloat(path, \"energy_full\"); err != nil {\n        return nil, errors.New(\"unable to parse energy_full\")\n    }\n// after: fall back to charge_* pair\nif b.Current, err = readFloat(path, \"energy_now\"); err == nil {\n    if b.Full, err = readFloat(path, \"energy_full\"); err != nil {\n        return nil, errors.New(\"unable to parse energy_full\")\n    }\n} else if b.Charge, err2 = readFloat(path, \"charge_now\"); err2 == nil { ... }","handlingStrategy":"try-catch","validationCode":"full, err := os.ReadFile(\"/sys/class/power_supply/BAT0/energy_full\")\nif err != nil || strings.TrimSpace(string(full)) == \"\" {\n    // battery data unavailable; skip segment\n}","typeGuard":null,"tryCatchPattern":"info, err := battery.Get()\nif err != nil {\n    if strings.Contains(err.Error(), \"energy_full\") {\n        return nil // sysfs node broken; skip segment\n    }\n    return err\n}","preventionTips":["Verify /sys/class/power_supply entries before enabling the battery segment","Reload battery drivers or reboot when sysfs values are empty","Guard the segment with a template conditional so one bad node doesn't break the prompt"],"tags":["battery","linux","sysfs","parsing"],"backgroundTag":"battery-sysfs-read-failed","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}