t8y2/dbx · error
ETCD_NEWKEY_REQUIRED
ETCD_NEWKEY_REQUIRED
Error message
ETCD_NEWKEY_REQUIRED
What it means
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.
Source
Thrown at agents/drivers/etcd-go/kv.go:381
response, err := client.Delete(ctx, key)
if err != nil {
return nil, err
}
return map[string]any{"deleted": response.Deleted, "revision": longString(response.Header.Revision)}, nil
}
func (s *etcdSession) rename(params map[string]json.RawMessage) (any, error) {
client, err := s.activeClient()
if err != nil {
return nil, err
}
sourceKey, err := keyBytesParam(params)
if err != nil {
return nil, err
}
newKey := stringOrNull(params, "newKey")
if newKey == nil || *newKey == "" {
return nil, errors.New("ETCD_NEWKEY_REQUIRED")
}
targetKey := *newKey
if sourceKey == targetKey {
return map[string]any{"renamed": true, "revision": nil}, nil
}
ctx, cancel := s.beginOperation()
defer s.endOperation(cancel)
sourceResponse, err := client.Get(ctx, sourceKey)
if err != nil {
return nil, err
}
if len(sourceResponse.Kvs) == 0 {
return nil, errors.New("ETCD_NOT_FOUND: source key does not exist")
}
source := sourceResponse.Kvs[0]
expected := longOrNull(params, "expectedModRevision")
expectedRevision := source.ModRevisionView on GitHub (pinned to c0390bff16)
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.
Example fix
// before
rename(session, key, { newKey: newName }); // newName === ''
// after
if (!newName) throw new Error('destination key required');
rename(session, key, { newKey: newName }); Defensive patterns
Strategy: validation
Validate before calling
if (typeof newKey !== 'string' || newKey.length === 0) {
throw new Error('rename requires a non-empty newKey');
} Type guard
function hasValidNewKey(p) { return typeof p.newKey === 'string' && p.newKey.length > 0; } Try / catch
try { return rename(session, sourceKey, { newKey }); }
catch (e) {
if (String(e).includes('ETCD_NEWKEY_REQUIRED'))
throw new Error('caller bug: rename invoked without destination key');
throw e;
} Prevention
- 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.
When it happens
Trigger: Calling the rename operation without a newKey parameter, with newKey: "", or with newKey: null/undefined.
Common situations: 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.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- lease, ttl, and preserveLease cannot be specified together
- ETCD_NEWKEY_REQUIRED
- user is required
- ttl must be a positive integer
- ETCD_NOT_FOUND
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/0527068f71bcd34d.
Report an issue: GitHub.