wavetermdev/waveterm · error
json syntax error at line %d, col %d: %v
Error message
json syntax error at line %d, col %d: %v
What it means
Generic JSON syntax error wrapper emitted while reading Wave configuration files: when json.SyntaxError occurs and it is not detected as a trailing comma, the error is reported as 'json syntax error at line %d, col %d' with the raw syntax error appended. Results are collected as ConfigError and surfaced by GenerateWshClient, GenerateWaveObjMetaConsts, and GenerateSettingsMetaConsts.
Source
Thrown at pkg/wconfig/settingsconfig.go:540
cerrs = append(cerrs, ConfigError{File: fileName, Err: readErr.Error()})
}
if len(barr) == 0 {
return nil, cerrs
}
var rtn waveobj.MetaMapType
err := json.Unmarshal(barr, &rtn)
if err != nil {
if syntaxErr, ok := err.(*json.SyntaxError); ok {
offset := syntaxErr.Offset
if offset > 0 {
offset = offset - 1
}
lineNum, colNum := utilfn.GetLineColFromOffset(barr, int(offset))
isTrailingComma := isTrailingCommaError(barr, int(offset))
if isTrailingComma {
err = fmt.Errorf("json syntax error at line %d, col %d: probably an extra trailing comma: %v", lineNum, colNum, syntaxErr)
} else {
err = fmt.Errorf("json syntax error at line %d, col %d: %v", lineNum, colNum, syntaxErr)
}
}
cerrs = append(cerrs, ConfigError{File: fileName, Err: err.Error()})
}
// Resolve environment variable replacements
if rtn != nil {
resolveEnvReplacements(rtn)
}
return rtn, cerrs
}
func readConfigFileFS(fsys fs.FS, logPrefix string, fileName string) (waveobj.MetaMapType, []ConfigError) {
barr, readErr := fs.ReadFile(fsys, fileName)
if readErr != nil {
// If we get an error, we may be using the wrong path separator for the given FS interface. Try switching the separator.
barr, readErr = fs.ReadFile(fsys, filepath.ToSlash(fileName))View on GitHub (pinned to a4447c1563)
Solutions
- Go to the reported line/column and fix the syntax error indicated by the wrapped message
- Validate the whole file with a strict JSON parser to catch additional errors
- Restore the file from a backup or let Wave regenerate defaults if the file is corrupted
- Check for editor auto-substitutions (smart quotes) or unescaped backslashes in strings
Example fix
// before (settings.json)
{ 'term:disable': false }
// after
{ "term:disable": false } Defensive patterns
Strategy: validation
Validate before calling
if err := json.Valid(data); !err {
var se *json.SyntaxError
json.Unmarshal(data, &any) // force syntax error capture
_ = se
return fmt.Errorf("invalid JSON config")
} Try / catch
if err := readConfig(); err != nil {
var cerrs []wconfig.ConfigError
if errors.As(err, &cerrs) {
for _, ce := range cerrs { log.Printf("%s: %s", ce.File, ce.Err) }
}
} Prevention
- Validate JSON with json.Valid or a linter before writing config files
- Avoid hand-editing; use Wave's config commands where possible
- Watch for smart quotes and unescaped backslashes introduced by editors
- Back up settings.json before bulk edits
When it happens
Trigger: Any malformed JSON in a Wave config file other than a trailing comma: unclosed braces, unquoted keys, single quotes, invalid escapes, stray characters at the reported line/col.
Common situations: Typos when hand-editing settings.json or presets files; partial file writes after a crash; accidentally saving the file as JSON5/JSONC syntax that strict JSON rejects; template placeholders like {{var}} left unexpanded.
Related errors
- json syntax error at line %d, col %d: probably an extra trai
- error reading config file: %v
- failed to marshal backup metadata: %w
- invalid format of user@host argument
- unexpected output from uname: %s
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/8b19d2ebe77e043d.
Report an issue: GitHub.