beekeeper-studio/beekeeper-studio · error

No pin found.

Error message

No pin found.

What it means

UserPin.verifyPin compares a candidate pin against the stored bcrypt hash. If no UserPin row exists at all (count === 0) it throws "No pin found." instead of returning false, because there is nothing to compare against — verification requires a pin to have been set.

Source

Thrown at apps/studio/src/common/appdb/models/UserPin.ts:55

    }

    const isOldPinCorrect = await UserPin.verifyPin(oldPin, userPin);
    if (!isOldPinCorrect) {
      throw new Error("Old pin is incorrect");
    }

    if (newPin.length < bksConfig.security.minPinLength) {
      throw new Error(`Pin must be at least ${bksConfig.security.minPinLength} characters long`);
    }

    userPin.hash = await bcrypt.hash(newPin, saltRounds);

    return await userPin.save();
  }

  static async verifyPin(pin: string, userPin?: UserPin): Promise<boolean> {
    if ((await UserPin.count()) === 0) {
      throw new Error("No pin found.");
    }
    if (!userPin) {
      userPin = (await UserPin.find())[0];
    }
    return await bcrypt.compare(pin, userPin.hash);
  }
}

View on GitHub (pinned to 4e3e03e322)

Solutions

  1. Check UserPin.count() > 0 before calling verifyPin; skip pin verification entirely when none is set.
  2. Create a pin first (UserPin.createPin) if the feature requires one.
  3. Catch the error and treat it as 'pin not configured' to route the user to setup instead of unlock.

Example fix

// before
const ok = await UserPin.verifyPin(input);
// after
if ((await UserPin.count()) === 0) {
  return; // no pin configured, nothing to verify
}
const ok = await UserPin.verifyPin(input);
Defensive patterns

Strategy: validation

Validate before calling

const pinConfigured = (await UserPin.count()) > 0;
if (!pinConfigured) {
  return; // nothing to verify; skip unlock or route to setup
}

Try / catch

try {
  const ok = await UserPin.verifyPin(input);
} catch (e) {
  if (e.message === 'No pin found.') {
    // treat as 'pin not configured' — route to setup flow
  }
}

Prevention

When it happens

Trigger: Calling UserPin.verifyPin(pin) (with or without an explicit userPin argument) when UserPin.count() === 0 — e.g. unlock or auth checks running before any pin was created.

Common situations: Unlock prompt shown on a fresh install with no pin configured; app databases wiped or migrated without the pin table populated; tests calling verifyPin before seeding a pin.

Related errors


AI-assisted analysis of beekeeper-studio/beekeeper-studio@4e3e03e322 (2026-08-31). Data as JSON: /api/errors/01ec426012c0b073. Report an issue: GitHub.