{"record":{"id":"0c850c50a135190c","repo":"ipfs/kubo","slug":"unexpected-message-from-dag-import","errorCode":null,"errorMessage":"unexpected message from DAG import","messagePattern":"unexpected message from DAG import","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/dag/dag.go","lineNumber":242,"sourceCode":"\t\tcmds.BoolOption(statsOptionName, \"Output stats.\"),\n\t\tcmds.BoolOption(fastProvideRootOptionName, \"Immediately provide root CIDs to DHT in addition to regular queue, for faster discovery. Default: Import.FastProvideRoot\"),\n\t\tcmds.BoolOption(fastProvideDAGOptionName, \"Walk and provide the full DAG according to Provide.Strategy after import. Default: Import.FastProvideDAG\"),\n\t\tcmds.BoolOption(fastProvideWaitOptionName, \"Block until the immediate provide completes before returning. Default: Import.FastProvideWait\"),\n\t\tcmdutils.AllowBigBlockOption,\n\t},\n\tType: CarImportOutput{},\n\tRun:  dagImport,\n\tEncoders: cmds.EncoderMap{\n\t\tcmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, event *CarImportOutput) error {\n\t\t\tsilent, _ := req.Options[silentOptionName].(bool)\n\t\t\tif silent {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// event should have only one of `Root` or `Stats` set, not both\n\t\t\tif event.Root == nil {\n\t\t\t\tif event.Stats == nil {\n\t\t\t\t\treturn fmt.Errorf(\"unexpected message from DAG import\")\n\t\t\t\t}\n\t\t\t\tstats, _ := req.Options[statsOptionName].(bool)\n\t\t\t\tif stats {\n\t\t\t\t\tfmt.Fprintf(w, \"Imported %d blocks (%d bytes)\\n\", event.Stats.BlockCount, event.Stats.BlockBytesCount)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tif event.Stats != nil {\n\t\t\t\treturn fmt.Errorf(\"unexpected message from DAG import\")\n\t\t\t}\n\n\t\t\tenc, err := cmdenv.GetCidEncoder(req)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif event.Root.PinErrorMsg != \"\" {","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/dag/dag.go#L224-L260","documentation":"'ipfs dag import' received a progress event carrying Stats from the CAR importer after the import had already completed (a Stats-bearing event arrived when only a final Root message was expected, or a duplicate completion message). This indicates an importer state-machine violation rather than bad user input.","triggerScenarios":"Thrown at core/commands/dag/dag.go:242 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run the import; transient importer state bugs may not recur","Verify the CAR file is well-formed with 'ipfs dag export' round-trip or a CAR validator","Report repeated occurrences with the CAR metadata to the kubo tracker"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}