{"record":{"id":"e1fdf133ac8e8c19","repo":"ipfs/kubo","slug":"failed-to-put-key-w","errorCode":null,"errorMessage":"failed to put key: %w","messagePattern":"failed to put key: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/diag.go","lineNumber":252,"sourceCode":"WARNING: FOR DEBUGGING/TESTING ONLY\n`,\n\t},\n\tArguments: []cmds.Argument{\n\t\tcmds.StringArg(\"key\", true, false, \"Datastore key (e.g., /test/mykey)\"),\n\t\tcmds.StringArg(\"value\", true, false, \"Value to store (as a string)\"),\n\t},\n\tNoRemote: true,\n\tPreRun:   DaemonNotRunning,\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tds, closer, err := openDiagDatastore(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer closer()\n\n\t\tkey := datastore.NewKey(req.Arguments[0])\n\t\tif err := ds.Put(req.Context, key, []byte(req.Arguments[1])); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to put key: %w\", err)\n\t\t}\n\t\tif err := ds.Sync(req.Context, key); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to sync: %w\", err)\n\t\t}\n\t\treturn nil\n\t},\n}\n\ntype diagDatastoreCountResult struct {\n\tPrefix string `json:\"prefix\"`\n\tCount  int64  `json:\"count\"`\n}\n\nvar diagDatastoreCountCmd = &cmds.Command{\n\tStatus: cmds.Experimental,\n\tHelptext: cmds.HelpText{\n\t\tTagline: \"Count entries matching a datastore prefix.\",\n\t\tShortDescription: `","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/diag.go#L234-L270","documentation":"'ipfs diag ds put' failed to write the given value under the given key in the debugging datastore. %w is the underlying datastore.Put error; typical causes are an invalid key prefix, a locked datastore (daemon running), or a disk-level failure. Debugging/testing command only.","triggerScenarios":"Thrown at core/commands/diag.go:252 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the daemon is not running (PreRun DaemonNotRunning) so the datastore is not locked","Use a valid datastore key such as /test/mykey","Check disk health and permissions on the repo directory"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}