{"record":{"id":"373864ea7476573c","repo":"OpenNHP/opennhp","slug":"key-not-found","errorCode":null,"errorMessage":"key not found","messagePattern":"key not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/etcd/etcdconn.go","lineNumber":63,"sourceCode":"\t}\n\tctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)\n\tdefer cancel()\n\tconn.ctx = ctx\n\t_, err = conn.client.Status(conn.ctx, conn.Endpoints[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc (conn *EtcdConn) GetValue() ([]byte, error) {\n\tval, err := conn.client.Get(conn.ctx, conn.Key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(val.Kvs) == 0 {\n\t\treturn nil, errors.New(\"key not found\")\n\t}\n\tif len(val.Kvs[0].Value) == 0 {\n\t\treturn nil, errors.New(\"value not set\")\n\t}\n\treturn val.Kvs[0].Value, nil\n}\n\nfunc (conn *EtcdConn) SetValue(v string) error {\n\t_, err := conn.client.Put(conn.ctx, conn.Key, v)\n\treturn err\n}\n\nfunc (conn *EtcdConn) WatchValue(callbackFunc func(val []byte)) {\n\t// create etcd watcher\n\tconn.watcher = clientv3.NewWatcher(conn.client)\n\n\twatchChan := conn.watcher.Watch(context.Background(), conn.Key)\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/etcd/etcdconn.go#L45-L81","documentation":"EtcdConn.GetValue fetches the key configured on the connection from etcd. If the Get succeeds but etcd returns zero key-value records, the key simply does not exist in the cluster and this error is returned, aborting remote config loading in the AC/server.","triggerScenarios":"loadRemoteConfig (AC) or loadRemoteBaseConfig (server) calls GetValue while the etcd key was never written, was deleted, or the connection points at the wrong namespace/prefix/key name.","commonSituations":"Fresh etcd cluster not yet seeded with config; key deleted by TTL or compaction; config Key field pointing at a different path than where the operator stored the value; wrong etcd endpoints/environment selected.","solutions":["Put the config value into etcd at the exact configured key (etcdctl put <key> '<value>')","Compare conn.Key with the key actually present (etcdctl get <key> --prefix)","Point the config at the correct etcd endpoints/environment where the key exists","Re-run the seeding script/tool that writes remote config on deploy"],"exampleFix":"// before (empty cluster)\netcdctl get /opennhp/server/config  # empty\n// after\netcdctl put /opennhp/server/config '{...}'\netcdctl get /opennhp/server/config","handlingStrategy":"retry","validationCode":"// before starting daemons\nresp, err := etcdCli.Get(ctx, key)\nif err != nil { return err }\nif resp.Count == 0 {\n    return fmt.Errorf(\"seed etcd key %s before starting\", key)\n}","typeGuard":null,"tryCatchPattern":"val, err := conn.GetValue()\nif err != nil {\n    if err.Error() == \"key not found\" {\n        return fmt.Errorf(\"remote config key %q missing; run seeding script\", conn.Key)\n    }\n    return err\n}","preventionTips":["Seed etcd as a pre-start job that completes before daemons launch","Pin the exact key path in one shared constant across writer and reader","Monitor etcd for key deletion (TTL, compaction) with alerts"],"tags":["go","etcd","config"],"backgroundTag":"missing-config-key","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}