coder/code-server · error · Error
invalid config: ${config}
Error message
invalid config: ${config} What it means
parseConfigFile (cli.ts:763) loads the YAML config and expects an object. If the loader returns a falsy value (empty file) or a bare string (e.g. a single scalar with no key:), the result is not a usable config object and the function throws `invalid config: <value>`. This guards the downstream Object.entries conversion of the config into flags.
Source
Thrown at src/node/cli.ts:763
const configFile = await fs.readFile(configPath, "utf8")
return parseConfigFile(configFile, configPath)
}
/**
* parseConfigFile parses configFile into ConfigArgs.
* configPath is used as the filename in error messages
*/
export function parseConfigFile(configFile: string, configPath: string): ConfigArgs {
if (!configFile) {
return { config: configPath }
}
const config = load(configFile, {
filename: configPath,
})
if (!config || typeof config === "string") {
throw new Error(`invalid config: ${config}`)
}
// We convert the config file into a set of flags.
// This is a temporary measure until we add a proper CLI library.
const configFileArgv = Object.entries(config)
.map(([optName, opt]) => {
if (opt === true) {
return `--${optName}`
} else if (Array.isArray(opt)) {
return opt.map((o) => `--${optName}=${o}`)
}
return `--${optName}=${opt}`
})
.flat()
const args = parse(configFileArgv, {
configFile: configPath,
})
return {View on GitHub (pinned to 51f90a376b)
Solutions
- Ensure the config file contains at least one `key: value` pair, e.g. `auth: password`
- Validate the YAML with `python -c 'import yaml,sys; print(yaml.safe_load(open(sys.argv[1])))' config.yaml` and confirm it is a dict
- If the file is intentionally empty, delete it or set `config:` to a real path
Example fix
# before (config.yaml) # (empty or just a comment) # after (config.yaml) auth: password bind-addr: 127.0.0.1:8080
Defensive patterns
Strategy: try-catch
Validate before calling
import yaml from "js-yaml" // or the same loader code-server uses
function validateConfigFile(path: string): void {
const loaded = yaml.load(fs.readFileSync(path, "utf8"))
if (!loaded || typeof loaded !== "object" || Array.isArray(loaded)) {
throw new Error(`invalid config: ${loaded}`)
}
} Type guard
function isConfigObject(v: unknown): v is Record<string, unknown> {
return typeof v === "object" && v !== null && !Array.isArray(v)
} Try / catch
try {
const args = parseConfigFile(configFile, configPath)
} catch (e) {
if (e instanceof Error && e.message.startsWith("invalid config:")) {
throw new Error(`Config file at ${configPath} did not parse to an object. Check YAML syntax.`)
}
throw e
} Prevention
- Lint config.yaml in CI with a schema validator before deploy
- Never template a config file that may resolve to empty (guard missing vars)
- Keep a known-good config in version control to diff against
When it happens
Trigger: A config file that is empty, contains only a comment, or holds a single unkeyed scalar (e.g. just `hello` instead of `auth: password`). Also triggered by YAML that parses to a string via quoting quirks.
Common situations: Truncated config files from a bad deploy; hand-edited YAML where the top-level key was accidentally removed; templating that emitted an empty file on a missing variable.
Related errors
- Invalid JSON in custom strings file: ${filePath}\n${error.me
- Unsupported auth type ${req.args.auth}
- Custom strings file not found: ${filePath}\nPlease ensure th
- Failed to load custom strings from ${filePath}: ${error inst
- Please pass in a password via the config file or environment
AI-assisted analysis of coder/code-server@51f90a376b (2026-08-12).
Data as JSON: /api/errors/f83e62e6c000dd77.
Report an issue: GitHub.