ipfs/kubo · error

failed to decode multibase: %w

Error message

failed to decode multibase: %w

What it means

Failure in `ipfs multibase decode`: mbase.Decode could not parse the input string as any multibase — the data either lacks a valid multibase prefix character or is corrupted after the prefix. Wraps the underlying decode error; the encoder name is not needed since it is self-describing in multibase.

Source

Thrown at core/commands/multibase.go:114

	Arguments: []cmds.Argument{
		cmds.FileArg("encoded_file", true, false, "encoded data to decode").EnableStdin(),
	},
	Run: func(req *cmds.Request, resp cmds.ResponseEmitter, env cmds.Environment) error {
		if err := req.ParseBodyArgs(); err != nil {
			return err
		}
		files := req.Files.Entries()
		file, err := cmdenv.GetFileArg(files)
		if err != nil {
			return fmt.Errorf("failed to access file: %w", err)
		}
		encodedData, err := io.ReadAll(file)
		if err != nil {
			return fmt.Errorf("failed to read file contents: %w", err)
		}
		_, data, err := mbase.Decode(string(encodedData))
		if err != nil {
			return fmt.Errorf("failed to decode multibase: %w", err)
		}
		reader := bytes.NewReader(data)
		return resp.Emit(reader)
	},
}

var mbaseTranscodeCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline: "Transcode multibase string between bases",
		LongDescription: `
This command expects multibase inside of a file or via stdin.

By default it will use URL-safe base64url encoding,
but one can customize used base with -b:

  > echo -n hello | ipfs multibase encode > file
  > cat file
  uaGVsbG8

View on GitHub (pinned to 329838acdf)

Solutions

  1. Verify the input starts with a valid multibase prefix (e.g. 'u' for base64url, 'z' for base58btc)
  2. Re-copy the encoded string; trailing newlines or whitespace can corrupt it
  3. Re-encode the original data if the source is lost
Defensive patterns

Strategy: validation

When it happens

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

Common situations: See trigger scenarios.

Understand the failure class


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