{"record":{"id":"f9b84092da8a5b7a","repo":"t8y2/dbx","slug":"etcd-not-found-f9b840","errorCode":"ETCD_NOT_FOUND","errorMessage":"ETCD_NOT_FOUND: source key does not exist","messagePattern":"ETCD_NOT_FOUND: source key does not exist","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/etcd2-go/kv.go","lineNumber":309,"sourceCode":"\tsourceKey, err := keyBytesParam(params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnewKey := stringOrNull(params, \"newKey\")\n\tif newKey == nil || *newKey == \"\" {\n\t\treturn nil, errors.New(\"ETCD_NEWKEY_REQUIRED\")\n\t}\n\ttargetKey := *newKey\n\tif sourceKey == targetKey {\n\t\treturn map[string]any{\"renamed\": true, \"revision\": nil}, nil\n\t}\n\n\tctx, cancel := s.beginOperation()\n\tdefer s.endOperation(cancel)\n\tbody, _, err := client.do(ctx, http.MethodGet, v2KeyPath(sourceKey), \"\", nil)\n\tif err != nil {\n\t\tif isNotFound(err) {\n\t\t\treturn nil, errors.New(\"ETCD_NOT_FOUND: source key does not exist\")\n\t\t}\n\t\treturn nil, err\n\t}\n\tvar source v2KeysResponse\n\tif err := json.Unmarshal(body, &source); err != nil {\n\t\treturn nil, err\n\t}\n\tif source.Node == nil || source.Node.Dir {\n\t\treturn nil, errors.New(\"ETCD_NOT_FOUND: source key does not exist\")\n\t}\n\tif _, _, err := client.do(ctx, http.MethodGet, v2KeyPath(targetKey), \"\", nil); err == nil {\n\t\treturn nil, errors.New(\"ETCD_CAS_CONFLICT: source changed or target already exists\")\n\t} else if !isNotFound(err) {\n\t\treturn nil, err\n\t}\n\n\texpected := longOrNull(params, \"expectedModRevision\")\n\texpectedRevision := source.Node.ModifiedIndex","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/etcd2-go/kv.go#L291-L327","documentation":"rename first GETs the source key to read its value and metadata. If etcd responds 100 Key not found, the driver refuses to proceed with this error, since there is nothing to rename. The rename is not performed.","triggerScenarios":"Calling rename where the source key does not exist in etcd — it was never created, already renamed/deleted by another process, or the key path is wrong (missing prefix, wrong namespace).","commonSituations":"Typos in key names or missing leading slash; a previous rename already moved the key so a retry hits a missing source; environment mismatch (pointing at a different etcd namespace/cluster than the writer); TTL expiry removed the key.","solutions":["GET the source key first to confirm it exists before renaming.","Check the key spelling, leading '/', and any prefix/namespace used by other tools writing this key.","If a concurrent process may have renamed it already, treat this as success (idempotent rename).","Verify you are connected to the expected etcd endpoint/cluster."],"exampleFix":"// before\nres, err := agent.Handle(ctx, \"rename\", map[string]any{\"key\": \"cfg/old\", \"newKey\": \"cfg/new\"})\n// after\nif _, err := agent.Handle(ctx, \"get\", map[string]any{\"key\": \"cfg/old\"}); err != nil {\n    return fmt.Errorf(\"source missing, skip rename: %w\", err)\n}\nres, err := agent.Handle(ctx, \"rename\", map[string]any{\"key\": \"cfg/old\", \"newKey\": \"cfg/new\"})","handlingStrategy":"try-catch","validationCode":"if _, err := agent.Handle(ctx, \"get\", map[string]any{\"key\": sourceKey}); err != nil {\n    return fmt.Errorf(\"source %q missing, cannot rename: %w\", sourceKey, err)\n}","typeGuard":"func isNotFound(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"ETCD_NOT_FOUND\")\n}","tryCatchPattern":"_, err := agent.Handle(ctx, \"rename\", params)\nif isNotFound(err) {\n    // key already renamed/deleted elsewhere: log and treat as no-op, or fail the migration step explicitly\n}","preventionTips":["GET the source before renaming to confirm existence","Double-check key spelling, leading '/', and namespace prefix","Make migration scripts idempotent: missing source + existing target = already done","Verify the etcd endpoint/cluster matches the environment that wrote the key"],"tags":["etcd","not-found","rename","key-missing"],"backgroundTag":"key-not-found","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}