amark/gun · error
User cannot be found!
Error message
User cannot be found!
What it means
This is the default error text in user.auth's act.err handler: when auth fails without a specific message (e === undefined), Gun logs 'User cannot be found!' and invokes the callback with { err }. It typically appears when the plugin/user lookup produced no name — e.g. act.plugin is called without a truthy name — or another internal auth failure path calls act.err() with no argument.
Source
Thrown at sea/auth.js:135
act.w(JSON.stringify({ek: auth, s: act.salt}));
}
act.w = function(auth){
if(opt.shuffle){ // delete in future!
console.log('migrate core account from UTF8 & shuffle');
var tmp = {}; Object.keys(act.data).forEach(function(k){ tmp[k] = act.data[k] });
delete tmp._;
tmp.auth = auth;
root.get('~'+act.pair.pub).put(tmp);
} // end delete
root.get('~'+act.pair.pub).get('auth').put(auth, cb || noop);
}
act.err = function(e){
var ack = {err: Gun.log(e || 'User cannot be found!')};
cat.ing = false;
(cb || noop)(ack);
}
act.plugin = function(name){
if(!(act.name = name)){ return act.err() }
var tmp = [name];
if('~' !== name[0]){
tmp[1] = '~'+name;
tmp[2] = '~@'+name;
}
act.b(tmp);
}
if(pair){
if(pair.priv && pair.epriv)
act.g(pair);
else
root.get('~'+pair.pub).once(act.h);
} else
if(alias){
root.get('~@'+alias).once(act.a);
} else
if(!alias && !pass){
SEA.name(act.plugin);View on GitHub (pinned to 552227599d)
Solutions
- Ensure both alias and password are non-empty strings at the call site
- Always supply the auth callback and read ack.err to see the real failure
- Complete user.create before attempting auth, and check its ack
- If using plugin-based auth, pass a truthy user/public key name
Example fix
// before — alias may be undefined
gun.user().auth(alias, pass);
// after
if (typeof alias !== 'string' || !alias || typeof pass !== 'string' || !pass) {
throw new Error('alias and password are required');
}
gun.user().auth(alias, pass, ack => {
if (ack.err) return console.error(ack.err);
}); Defensive patterns
Strategy: validation
Validate before calling
if (typeof alias !== 'string' || !alias.trim()) {
throw new Error('alias required for auth');
}
if (typeof pass !== 'string' || !pass) {
throw new Error('password required for auth');
} Type guard
const isCred = (s) => typeof s === 'string' && s.length > 0;
Try / catch
gun.user().auth(alias, pass, ack => {
if (ack && ack.err) {
console.error('auth error:', ack.err); // includes 'User cannot be found!' fallback
return;
}
}); Prevention
- Validate alias/password are non-empty strings before auth
- Await all async value resolution (form state, storage) before calling auth
- Always supply the callback and log ack.err to see the real cause
- Complete user.create successfully before authenticating
When it happens
Trigger: Calling user.auth with arguments so malformed that no alias/name could be derived (e.g. auth() with no alias, or a plugin path passing an empty/falsy name so act.plugin hits return act.err()); any auth failure where the specific error is undefined falls back to this message via Gun.log(e || 'User cannot be found!').
Common situations: Passing undefined alias/password variables (missing form fields, unawaited promise values); calling auth before user.create finished; custom plugin/integration code calling the internal act pipeline with a falsy name.
Related errors
- Your user account is not published for dApps to access, plea
- Wrong user or password.
- First argument must be a string, Buffer, ArrayBuffer, Array,
- Invalid first argument for type 'hex'.
- First argument must be Array containing ArrayBuffer or Uint8
AI-assisted analysis of amark/gun@552227599d (2026-09-02).
Data as JSON: /api/errors/08bd1268ee5b62b9.
Report an issue: GitHub.