ipfs/kubo · error

unexpected message from DAG import

Error message

unexpected message from DAG import

What it means

'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.

Source

Thrown at core/commands/dag/dag.go:242

		cmds.BoolOption(statsOptionName, "Output stats."),
		cmds.BoolOption(fastProvideRootOptionName, "Immediately provide root CIDs to DHT in addition to regular queue, for faster discovery. Default: Import.FastProvideRoot"),
		cmds.BoolOption(fastProvideDAGOptionName, "Walk and provide the full DAG according to Provide.Strategy after import. Default: Import.FastProvideDAG"),
		cmds.BoolOption(fastProvideWaitOptionName, "Block until the immediate provide completes before returning. Default: Import.FastProvideWait"),
		cmdutils.AllowBigBlockOption,
	},
	Type: CarImportOutput{},
	Run:  dagImport,
	Encoders: cmds.EncoderMap{
		cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, event *CarImportOutput) error {
			silent, _ := req.Options[silentOptionName].(bool)
			if silent {
				return nil
			}

			// event should have only one of `Root` or `Stats` set, not both
			if event.Root == nil {
				if event.Stats == nil {
					return fmt.Errorf("unexpected message from DAG import")
				}
				stats, _ := req.Options[statsOptionName].(bool)
				if stats {
					fmt.Fprintf(w, "Imported %d blocks (%d bytes)\n", event.Stats.BlockCount, event.Stats.BlockBytesCount)
				}
				return nil
			}

			if event.Stats != nil {
				return fmt.Errorf("unexpected message from DAG import")
			}

			enc, err := cmdenv.GetCidEncoder(req)
			if err != nil {
				return err
			}

			if event.Root.PinErrorMsg != "" {

View on GitHub (pinned to 329838acdf)

Solutions

  1. Re-run the import; transient importer state bugs may not recur
  2. Verify the CAR file is well-formed with 'ipfs dag export' round-trip or a CAR validator
  3. Report repeated occurrences with the CAR metadata to the kubo tracker
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at core/commands/dag/dag.go:242 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/0c850c50a135190c. Report an issue: GitHub.