ipfs/kubo · warning
no cid in path: %s
Error message
no cid in path: %s
What it means
CidEncoderFromPath extracts a CID from a path string to pick a matching output multibase encoder. If the path has no leading slash and fewer than 3 components (so no component can hold a CID), it gives up with 'no cid in path'.
Source
Thrown at core/commands/cmdenv/cidbase.go:87
// `CidLike`, `CidLike/...`, or `/namespace/CidLike/...`.
//
// For example:
//
// * Qm...
// * Qm.../...
// * /ipfs/Qm...
// * /ipns/bafybeiahnxfi7fpmr5wtxs2imx4abnyn7fdxeiox7xxjem6zuiioqkh6zi/...
// * /bzz/bafybeiahnxfi7fpmr5wtxs2imx4abnyn7fdxeiox7xxjem6zuiioqkh6zi/...
func CidEncoderFromPath(p string) (cidenc.Encoder, error) {
components := strings.SplitN(p, "/", 4)
var maybeCid string
if components[0] != "" {
// No leading slash, first component is likely CID-like.
maybeCid = components[0]
} else if len(components) < 3 {
// Not enough components to include a CID.
return cidenc.Encoder{}, fmt.Errorf("no cid in path: %s", p)
} else {
maybeCid = components[2]
}
c, err := cid.Decode(maybeCid)
if err != nil {
// Ok, not a CID-like thing. Keep the current encoder.
return cidenc.Encoder{}, fmt.Errorf("no cid in path: %s", p)
}
if c.Version() == 0 {
// Version 0, use the base58 non-upgrading encoder.
return cidenc.Default(), nil
}
// Version 1+, extract multibase encoding.
encoding, _, err := mbase.Decode(maybeCid)
if err != nil {
// This should be impossible, we've already decoded the cid.
panic(fmt.Sprintf("BUG: failed to get multibase decoder for CID %s", maybeCid))View on GitHub (pinned to 329838acdf)
Solutions
- Pass a full path containing a valid CID, e.g. /ipfs/<cid>/... or a 3-component path whose third element is the CID
- Treat the returned error as 'no encoder change needed' if your caller only uses this opportunistically (the function's contract allows callers to ignore it)
- Check whether the code path should be supplying a path at all
Example fix
// before
enc, _ := cmdenv.CidEncoderFromPath("foo/bar")
// after
enc, err := cmdenv.CidEncoderFromPath("/ipfs/bafybe.../") Defensive patterns
Strategy: fallback
Validate before calling
parts := strings.Split(path, "/") hasCid := len(parts) >= 3 || (len(parts) > 0 && parts[0] != "")
Try / catch
enc, err := cmdenv.CidEncoderFromPath(p)
if err != nil {
enc = cidenc.Default() // keep default encoder, non-fatal
} Prevention
- Only pass paths that contain a CID component
- Treat CidEncoderFromPath errors as advisory, not fatal
- Log-and-continue is the intended pattern for this helper
When it happens
Trigger: Calling cmdenv.CidEncoderFromPath(p) with a path like "foo/bar" (no leading '/', fewer than 3 components) or any string too short to contain a CID component.
Common situations: Passing bare keys, relative two-segment paths, or non-path identifiers from commands that only sometimes carry CIDs; tests constructing minimal path strings.
Related errors
- Import.CidVersion must be 0 or 1, got %d
- inline-limit %d exceeds maximum allowed size of %d bytes
- invalid format string: %q
- cannot convert to CIDv0 with any codec other than dag-pb
- cannot convert to CIDv0 with any multibase other than the im
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/3e0477e19850e3eb.
Report an issue: GitHub.