{"record":{"id":"0180e98ba2956186","repo":"juanfont/headscale","slug":"marshaling-expected-online-map-w","errorCode":null,"errorMessage":"marshaling expected online map: %w","messagePattern":"marshaling expected online map: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/mapresponses/main.go","lineNumber":59,"sourceCode":"\tcommand.RunOrFail(env, os.Args[1:])\n}\n\n// runIntegrationTest executes the integration test workflow.\nfunc runOnline(env *command.Env) error {\n\tif mapConfig.Directory == \"\" {\n\t\treturn errDirectoryRequired\n\t}\n\n\tresps, err := mapper.ReadMapResponsesFromDirectory(mapConfig.Directory)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading map responses from directory: %w\", err)\n\t}\n\n\texpected := integrationutil.BuildExpectedOnlineMap(resps)\n\n\tout, err := json.MarshalIndent(expected, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marshaling expected online map: %w\", err)\n\t}\n\n\tos.Stderr.Write(out)\n\tos.Stderr.Write([]byte(\"\\n\"))\n\n\treturn nil\n}\n","sourceCodeStart":41,"sourceCodeEnd":67,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/mapresponses/main.go#L41-L67","documentation":"json.MarshalIndent failed while serializing the expected online map built by integrationutil.BuildExpectedOnlineMap. Marshal only fails on unserializable Go values (channels, functions, cycles in the older encoder, +Inf/NaN floats, unsupported map key types). The expected map is built from parsed MapResponse data, so in practice this error is nearly unreachable — it would indicate a schema regression where an unsupported type leaked into the expected structure.","triggerScenarios":"BuildExpectedOnlineMap output containing a func/chan field, a map with a non-string/comparable-but-unsupported key, or NaN/Inf float values produced by degenerate capture data.","commonSituations":"Practically never in normal operation; only after introducing new field types into the expected-map structs without json tags or with unsupported underlying types.","solutions":["Treat it as a code defect: inspect what BuildExpectedOnlineMap produced (add a temporary debug print of the struct types)","Verify any newly added fields on the expected-map types are JSON-marshalable (no func/chan, json tags present)","If NaN floats can occur in captures, sanitize them to nil before building the expected map"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := json.MarshalIndent(expected, \"\", \"  \")\nif err != nil {\n    // practically unreachable for plain structs; if hit, log the type that broke marshaling\n    log.Printf(\"marshal failed: %v\", err)\n    return err\n}","preventionTips":["Keep expected-map structs limited to JSON-marshalable fields (no func/chan)","Sanitize NaN/Inf floats from captured data before building the expected map","Treat this error as a signal of a schema bug, not a data problem"],"tags":["json","mapresponses","serialization"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}