wavetermdev/waveterm · error
error formatting metadata: %v
Error message
error formatting metadata: %v
What it means
When --print is passed, setbg serializes the computed metadata map to indented JSON with json.MarshalIndent and prints it instead of applying it. json.MarshalIndent only fails if the map contains a value JSON cannot encode (channels, funcs, complex numbers, or cyclic structures). With the current meta values this is practically unreachable, so the error indicates an internal/logic bug rather than user input.
Source
Thrown at cmd/wsh/cmd/wshcmd-setbg.go:202
default:
bgStyle += " center/cover no-repeat"
}
}
meta["bg"] = bgStyle
}
if borderColorChanged {
meta["bg:bordercolor"] = setBgBorderColor
}
if activeBorderColorChanged {
meta["bg:activebordercolor"] = setBgActiveBorderColor
}
if setBgPrint {
jsonBytes, err := json.MarshalIndent(meta, "", " ")
if err != nil {
return fmt.Errorf("error formatting metadata: %v", err)
}
WriteStdout("%s\n", string(jsonBytes))
return nil
}
// Resolve tab reference
id := blockArg
if id == "" {
id = "tab"
}
oRef, err := resolveSimpleId(id)
if err != nil {
return err
}
// Send RPC request
setMetaWshCmd := wshrpc.CommandSetMetaData{
ORef: *oRef,View on GitHub (pinned to a4447c1563)
Solutions
- Re-run with --print to reproduce; if it fires on stock waveterm, report a bug to the Wave Terminal repository
- Check any local modifications to wshcmd-setbg.go for values placed into meta that are not JSON-marshalable (funcs, channels)
- Work around by omitting --print and applying the change directly
Defensive patterns
Strategy: try-catch
Try / catch
try {
const out = execSync(`wsh setbg ${args} --print`, { stdio: "pipe" });
console.log(out.toString());
} catch (e) {
if (String(e.stderr).includes("error formatting metadata")) {
console.error("Internal marshal failure — report a waveterm bug");
} else throw e;
} Prevention
- Treat this as a bug indicator, not a usage error
- Keep wsh binaries in sync with your waveterm version
- Report reproductions to the Wave Terminal issue tracker
When it happens
Trigger: Practically only when the metadata map ends up containing a non-JSON-encodable value — a code-level bug (e.g. a bad type stored into meta), not a user-input error. Normal user invocations of `wsh setbg --print ...` never hit this.
Common situations: Custom builds or patches to setbg that inject unsupported types into meta; otherwise essentially never encountered by end users.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- failed to marshal JSON: %v
- formatting version info: %v
- json encoding: %w
- no files or message provided
- too many files (maximum %d files allowed)
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/812ea467c23521c2.
Report an issue: GitHub.