{"record":{"id":"3ddc39d65a8584a9","repo":"ipfs/kubo","slug":"msg-server-provided-error-message","errorCode":null,"errorMessage":"msg (server-provided error message)","messagePattern":"msg \\(server-provided error message\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/rpc/errors.go","lineNumber":40,"sourceCode":"func (e prePostWrappedNotFoundError) String() string {\n\treturn e.Error()\n}\n\nfunc (e prePostWrappedNotFoundError) Error() string {\n\treturn e.pre + e.wrapped.Error() + e.post\n}\n\nfunc (e prePostWrappedNotFoundError) Unwrap() error {\n\treturn e.wrapped\n}\n\nfunc parseErrNotFoundWithFallbackToMSG(msg string) error {\n\terr, handled := parseErrNotFound(msg)\n\tif handled {\n\t\treturn err\n\t}\n\n\treturn errors.New(msg)\n}\n\nfunc parseErrNotFoundWithFallbackToError(msg error) error {\n\terr, handled := parseErrNotFound(msg.Error())\n\tif handled {\n\t\treturn err\n\t}\n\n\treturn msg\n}\n\nfunc parseErrNotFound(msg string) (error, bool) {\n\tif msg == \"\" {\n\t\treturn nil, true // Fast path\n\t}\n\n\tif err, handled := parseIPLDErrNotFound(msg); handled {\n\t\treturn err, true","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/client/rpc/errors.go#L22-L58","documentation":"parseErrNotFoundWithFallbackToMSG first tries to interpret the daemon's error string as a structured 'ipld not found' error; if it cannot, it returns the raw server-provided message wrapped in errors.New(msg). The message text is whatever the daemon sent, so its content is not produced by this library.","triggerScenarios":"Any RPC call (e.g. api.Object().Get, api.Dag().Get via this helper path) whose daemon response is an error that does not match the recognized 'not found under ...' pattern — for example a permission, timeout, or generic server error passed through this fallback.","commonSituations":"Daemon-side errors like 'file does not exist', blocked/permission errors, or new daemon error formats the old client does not recognize arriving during dag/object lookups.","solutions":["Read the message text: it is the daemon's own error, and the fix depends on what the daemon said (path missing, permission denied, timeout, etc.).","If the path truly exists, verify you are connecting to the intended node (Addresses.API / --api) and that the CID/path is correct.","Upgrade go-ipfs-api so more daemon error strings are parsed into typed errors instead of falling back to raw text."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isNotFound(err error) bool {\n    var nf iface.ErrIsDir // example narrowing; primary check is string pattern\n    if errors.As(err, &nf) { return true }\n    return strings.Contains(err.Error(), \"not found\")\n}","tryCatchPattern":"_, err := api.Dag().Get(ctx, p)\nif err != nil {\n    if strings.Contains(err.Error(), \"not found\") {\n        // handle absence\n    } else {\n        // raw server error; inspect message and daemon logs\n    }\n}","preventionTips":["Read the error message directly — it is the daemon's own failure reason","Verify you target the intended node (Addresses.API / --api) before debugging the message","Keep the client updated so more daemon errors parse into typed errors"],"tags":["http-rpc","server-error","not-found"],"backgroundTag":"server-error-passthrough","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"}