Solution skill
doctl: Config initialization failed: While parsing config: yaml: did not find expected key
Complete solution
Fixes doctl dying at startup with Config initialization failed: While parsing config after v1.158.0 writes a config file it cannot read back. Use when every doctl command, including auth init and auth list, fails with a yaml parse error at startup. Not for Unable to authenticate you after auth init, which is a bad token, not a broken config file.
doctl: Config initialization failed: While parsing config: yaml: did not find expected key
TL;DR: your doctl config file got mangled. doctl v1.158.0 writes a config.yaml that its own parser rejects, so every command dies at startup. Fix: move the broken config aside and re-run doctl auth init to generate a fresh one. If the problem comes back on that version, downgrade to v1.157.0, which reads the same file fine.
doctl: 2026/05/07 21:08:20 Config initialization failed: While parsing config: yaml: line 2228: did not find expected keySteps
- Back up the broken config, then remove it:
cp ~/.config/doctl/config.yaml ~/.config/doctl/config.yaml.bak
rm ~/.config/doctl/config.yamlExpected: no output. ls ~/.config/doctl/ no longer shows config.yaml.
- Re-authenticate to regenerate the config:
doctl auth initExpected: doctl prompts for your DigitalOcean access token, then prints a success message. A fresh config file is created.
- Verify auth works:
doctl auth listExpected: your context listed, e.g. default (current).
When this applies
- every doctl command fails at startup with
Config initialization failed: While parsing configand a yaml line number - the error names a line at or past the end of the file (the parser expects more YAML than the writer produced)
- it started right after upgrading doctl to v1.158.0
When it doesnt
Error: Unable to authenticate youafterdoctl auth init— that is a bad or expired token, not a config file problemdoctl: command not found— that is a PATH or install problem
Compatibility
doctl v1.158.0 (the broken writer). v1.157.0 reads the same files fine, and later releases fixed the writer. Config lives at ~/.config/doctl/config.yaml on Linux and macOS.
Why it happens
v1.158.0 shipped a config schema change for DOKS SSO per-cluster config (PR #1835). The serializer writes YAML the bundled parser cannot read back: it emits a truncated section, then expects more keys than exist. PyYAML parses the same file fine, so the file itself is valid YAML — the bug is doctl's own read path.
Edge cases
- In CI, prefer the DIGITALOCEANACCESSTOKEN env var over auth init so a bad config can never block a run
- If you had multiple contexts, re-add each one after regenerating; the .bak file keeps the old values for reference (keep it out of version control)
- The same failure also shows up worded as
could not find expected ':'
Find this skill again
curl -s 'https://vectle.com/api/v1/search?q=doctl+config+initialization+failed+yaml'Evidence
A doctl user reported that v1.158.0 could not read its own config files: every invocation, including auth init and auth list, failed at startup with Config initialization failed: While parsing config: yaml: line 2228: did not find expected key, while v1.157.0 read the identical file fine. The verified fix: delete the mangled config.yaml and re-run doctl auth init to regenerate it, or downgrade to v1.157.0. Source: https://github.com/digitalocean/doctl/issues/1842
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_2Ae2RH-2EWlozOCfbSuv6A" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">doctl: Config initialization failed: While parsing config: yaml: did not find expected key <span>— Vectle</span></a>