ipfs/kubo · error
unknown data field encoding
Error message
unknown data field encoding
What it means
ErrDataEncoding is a sentinel error exported by the deprecated `ipfs object` command family. The legacy `object` commands can render a DAG node's data field only in the encodings they know; when asked for an unknown data encoding they return this error. The whole ObjectCmd group is marked Deprecated in favor of `ipfs dag` and `ipfs files`.
Source
Thrown at core/commands/object/object.go:19
package objectcmd
import (
"errors"
cmds "github.com/ipfs/go-ipfs-cmds"
)
type Link struct {
Name, Hash string
Size uint64
}
type Object struct {
Hash string `json:"Hash,omitempty"`
Links []Link `json:"Links,omitempty"`
}
var ErrDataEncoding = errors.New("unknown data field encoding")
var ObjectCmd = &cmds.Command{
Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936
Helptext: cmds.HelpText{
Tagline: "Deprecated commands to interact with dag-pb objects. Use 'dag' or 'files' instead.",
ShortDescription: `
'ipfs object' is a legacy plumbing command used to manipulate dag-pb objects
directly. Deprecated, use more modern 'ipfs dag' and 'ipfs files' instead.`,
},
Subcommands: map[string]*cmds.Command{
"data": RemovedObjectCmd,
"diff": ObjectDiffCmd,
"get": RemovedObjectCmd,
"links": RemovedObjectCmd,
"new": RemovedObjectCmd,
"patch": ObjectPatchCmd,
"put": RemovedObjectCmd,View on GitHub (pinned to 329838acdf)
Solutions
- Migrate to `ipfs dag get <cid>` (with --output-codec for format conversion) instead of `ipfs object`.
- Use `ipfs files` / MFS commands for filesystem-style operations previously done via `ipfs object`.
- If an encoding value was passed, correct it to one the legacy command accepts, or better, drop the deprecated call.
Example fix
// before ipfs object get --data-encoding=bogus <cid> // after ipfs dag get <cid> # or: ipfs dag get <cid> --output-codec=raw
Defensive patterns
Strategy: fallback
Validate before calling
// validate encoding against the set the legacy command supports before calling
var validEncodings = map[string]struct{}{"text": {}, "base64": {}}
if _, ok := validEncodings[encoding]; !ok {
encoding = "base64" // or refuse
} Try / catch
// err is the sentinel; compare directly, no unwrap needed
if err := cmd.Run(); err != nil && errors.Is(err, object.ErrDataEncoding) {
// fall back to `ipfs dag get`
} Prevention
- Treat the `ipfs object` tree as deprecated; use `ipfs dag`/`ipfs files` in new code.
- Whitelist encoding values in scripts before invoking.
- Watch for cmds.Deprecated status on commands before adopting them.
When it happens
Trigger: Calling a legacy object subcommand (e.g. `ipfs object get <cid>` variants that accept a data encoding option) with an unsupported encoding value; programmatically invoking the ObjectCmd tree with an invalid encoding argument.
Common situations: Users still on the deprecated `ipfs object` API (issue #7936) passing typos or encodings supported by newer `dag` tooling; scripts written against old kubo versions run on current ones.
Related errors
- can't convert non-dag-pb nodes to cidv0
- ErrNotDHT
- removed, use 'ipfs routing' instead
- %w: %v
- reading new root block: %w
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/f3cc8f88ab0cad5f.
Report an issue: GitHub.