{"record":{"id":"0527068f71bcd34d","repo":"t8y2/dbx","slug":"etcd-newkey-required","errorCode":"ETCD_NEWKEY_REQUIRED","errorMessage":"ETCD_NEWKEY_REQUIRED","messagePattern":"ETCD_NEWKEY_REQUIRED","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/etcd-go/kv.go","lineNumber":381,"sourceCode":"\tresponse, err := client.Delete(ctx, key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn map[string]any{\"deleted\": response.Deleted, \"revision\": longString(response.Header.Revision)}, nil\n}\n\nfunc (s *etcdSession) rename(params map[string]json.RawMessage) (any, error) {\n\tclient, err := s.activeClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\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\tsourceResponse, err := client.Get(ctx, sourceKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(sourceResponse.Kvs) == 0 {\n\t\treturn nil, errors.New(\"ETCD_NOT_FOUND: source key does not exist\")\n\t}\n\tsource := sourceResponse.Kvs[0]\n\texpected := longOrNull(params, \"expectedModRevision\")\n\texpectedRevision := source.ModRevision","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/etcd-go/kv.go#L363-L399","documentation":"Required-parameter error thrown by rename at kv.go:381. Renaming a key needs a target path, and the driver enforces that the newKey parameter is present and non-empty; otherwise it returns this bare sentinel code. It is a pure input validation — no etcd call is made.","triggerScenarios":"Calling the rename operation without a newKey parameter, with newKey: \"\", or with newKey: null/undefined.","commonSituations":"Dynamically built params objects where the target name variable was empty/undefined; form/UI submissions with a blank destination field; renaming scripts missing a required argument.","solutions":["Pass a non-empty newKey string, e.g. rename(session, 'old/key', { newKey: 'new/key' }).","Validate newKey truthiness in caller code before invoking rename.","If you meant a copy instead of a rename, supply the destination path explicitly.","Fix upstream defaults so the target name is always populated."],"exampleFix":"// before\nrename(session, key, { newKey: newName }); // newName === ''\n// after\nif (!newName) throw new Error('destination key required');\nrename(session, key, { newKey: newName });","handlingStrategy":"validation","validationCode":"if (typeof newKey !== 'string' || newKey.length === 0) {\n  throw new Error('rename requires a non-empty newKey');\n}","typeGuard":"function hasValidNewKey(p) { return typeof p.newKey === 'string' && p.newKey.length > 0; }","tryCatchPattern":"try { return rename(session, sourceKey, { newKey }); }\ncatch (e) {\n  if (String(e).includes('ETCD_NEWKEY_REQUIRED'))\n    throw new Error('caller bug: rename invoked without destination key');\n  throw e;\n}","preventionTips":["Validate newKey (non-empty string) before every rename call.","Reject empty/whitespace destination values at the UI/config layer.","For dynamic destinations, assert the template variable resolved to a value.","Add rename calls behind a small wrapper that enforces the parameter."],"tags":["etcd","rename","validation","params"],"backgroundTag":"missing-required-parameter","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}