{"record":{"id":"343f32eb1f988c8e","repo":"abiosoft/colima","slug":"error-decoding-networks-into-struct-w","errorCode":null,"errorMessage":"error decoding networks into struct: %w","messagePattern":"error decoding networks into struct: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/container/incus/incus.go","lineNumber":395,"sourceCode":"}\n\nfunc (c incusRuntime) addDockerRemote() error {\n\tif c.hasRemote(\"docker\") {\n\t\t// already added\n\t\treturn nil\n\t}\n\n\treturn c.host.RunQuiet(\"incus\", \"remote\", \"add\", \"docker\", \"https://docker.io\", \"--protocol=oci\")\n}\n\nfunc (c incusRuntime) findNetwork(interfaceName string) (found bool, info networkInfo, err error) {\n\tb, err := c.guest.RunOutput(\"sudo\", \"incus\", \"network\", \"list\", \"--format\", \"json\")\n\tif err != nil {\n\t\treturn found, info, fmt.Errorf(\"error listing networks: %w\", err)\n\t}\n\tvar resp []networkInfo\n\tif err := json.NewDecoder(strings.NewReader(b)).Decode(&resp); err != nil {\n\t\treturn found, info, fmt.Errorf(\"error decoding networks into struct: %w\", err)\n\t}\n\tfor _, n := range resp {\n\t\tif n.Name == interfaceName {\n\t\t\treturn true, n, nil\n\t\t}\n\t}\n\n\treturn\n}\n\n//go:embed config.yaml\nvar configYaml string\n\ntype remoteInfo map[string]struct {\n\tAddr string `json:\"Addr\"`\n}\n\ntype networkInfo struct {","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/container/incus/incus.go#L377-L413","documentation":"The JSON output of guest 'sudo incus network list --format json' could not be unmarshalled into []networkInfo. The incus daemon in the guest emitted JSON whose shape does not match colima's struct — typically a guest incus version newer or older than the schema colima was built against.","triggerScenarios":"json.Decode into []networkInfo fails: guest incus output schema changed (field types/names), non-JSON prefix in output, or truncated output when the SSH stream breaks mid-read.","commonSituations":"Guest VM image shipped with an incus version different from the one colima expects (version skew after upgrading colima without recreating the VM), custom guest images with a different incus build.","solutions":["Inspect the raw output: 'colima ssh -- sudo incus network list --format json' and compare to colima's networkInfo fields","Align versions: upgrade colima, or recreate the VM so guest incus matches: 'colima delete && colima start'","Update guest incus inside the VM to the version colima supports","Report the schema diff as a colima issue if versions match and it still fails"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// decode leniently: strict=false tolerates added fields from newer incus\ndec := json.NewDecoder(strings.NewReader(b))\ndec.DisallowUnknownFields() // remove this if set; default decode ignores unknown fields\nvar resp []networkInfo\nif err := dec.Decode(&resp); err != nil {\n    return found, info, fmt.Errorf(\"error decoding networks into struct: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"var resp []networkInfo\nif err := json.Unmarshal([]byte(b), &resp); err != nil {\n    if !json.Valid([]byte(b)) {\n        return found, info, fmt.Errorf(\"guest incus emitted non-JSON (version skew?): %w\", err)\n    }\n    return found, info, fmt.Errorf(\"schema mismatch, align colima and guest incus: %w\", err)\n}","preventionTips":["Recreate the VM when upgrading colima across minor versions so guest incus matches","Do not swap the guest incus binary manually","Pin colima and guest image versions together in team setups"],"tags":["incus","json","parsing","versioning","vm"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}