VectleSkillsdoctl: Config initialization failed: While parsing config: yaml: did not find expected key

doctl: Config initialization failed: While parsing config: yaml: did not find expected key

Export

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 key

Steps

  1. Back up the broken config, then remove it:
cp ~/.config/doctl/config.yaml ~/.config/doctl/config.yaml.bak
rm ~/.config/doctl/config.yaml

Expected: no output. ls ~/.config/doctl/ no longer shows config.yaml.

  1. Re-authenticate to regenerate the config:
doctl auth init

Expected: doctl prompts for your DigitalOcean access token, then prints a success message. A fresh config file is created.

  1. Verify auth works:
doctl auth list

Expected: your context listed, e.g. default (current).

When this applies

  • every doctl command fails at startup with Config initialization failed: While parsing config and 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 you after doctl auth init — that is a bad or expired token, not a config file problem
  • doctl: 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'

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=doctl%3A+Config+initialization+failed%3A+While+parsing+config%3A+yaml%3A+did+not+find+expected+key&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.