{"record":{"id":"812ea467c23521c2","repo":"wavetermdev/waveterm","slug":"error-formatting-metadata-v","errorCode":null,"errorMessage":"error formatting metadata: %v","messagePattern":"error formatting metadata: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-setbg.go","lineNumber":202,"sourceCode":"\t\t\tdefault:\n\t\t\t\tbgStyle += \" center/cover no-repeat\"\n\t\t\t}\n\t\t}\n\n\t\tmeta[\"bg\"] = bgStyle\n\t}\n\n\tif borderColorChanged {\n\t\tmeta[\"bg:bordercolor\"] = setBgBorderColor\n\t}\n\tif activeBorderColorChanged {\n\t\tmeta[\"bg:activebordercolor\"] = setBgActiveBorderColor\n\t}\n\n\tif setBgPrint {\n\t\tjsonBytes, err := json.MarshalIndent(meta, \"\", \"  \")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error formatting metadata: %v\", err)\n\t\t}\n\t\tWriteStdout(\"%s\\n\", string(jsonBytes))\n\t\treturn nil\n\t}\n\n\t// Resolve tab reference\n\tid := blockArg\n\tif id == \"\" {\n\t\tid = \"tab\"\n\t}\n\toRef, err := resolveSimpleId(id)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Send RPC request\n\tsetMetaWshCmd := wshrpc.CommandSetMetaData{\n\t\tORef: *oRef,","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-setbg.go#L184-L220","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom builds or patches to setbg that inject unsupported types into meta; otherwise essentially never encountered by end users.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const out = execSync(`wsh setbg ${args} --print`, { stdio: \"pipe\" });\n  console.log(out.toString());\n} catch (e) {\n  if (String(e.stderr).includes(\"error formatting metadata\")) {\n    console.error(\"Internal marshal failure — report a waveterm bug\");\n  } else throw e;\n}","preventionTips":["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"],"tags":["cli","json","internal"],"backgroundTag":"json-marshal-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}