beekeeper-studio/beekeeper-studio · error

Error updating preset id: ${id}

Error message

Error updating preset id: ${id}

What it means

updatePreset() wraps its whole body in try/catch; ANY failure — including the internal 'Preset not found' throw, JSON.stringify/parse problems, or a TypeORM save error — is logged with the underlying cause and rethrown as 'Error updating preset id: <id>'. The message conflates not-found with actual save failures.

Source

Thrown at apps/studio/src/common/appdb/models/FormatterPreset.ts:94

      throw new Error(`Error adding new preset`)
    }
  }

  static async updatePreset(id: number, updateValues: FormatterPresetValues): Promise<TransportFormatterPreset>{
    const existing = await this.findOne({ where: { id } })
    const { config } = updateValues
    try {
      if (!existing) throw new Error('Preset not found')
      existing.config = JSON.stringify(config)
      const savedFormat = await existing.save()
      return {
        ...savedFormat,
        config: JSON.parse(savedFormat.config),
        systemDefault: Boolean(savedFormat.systemDefault)
      }
    } catch (e) {
      log.error(`Error updating preset id: ${id}`, e)
      throw new Error(`Error updating preset id: ${id}`)
    }
  }

  static async deletePreset(id: number): Promise<void> {
    try {
      const result = await this.delete(id)
      if (result.affected === 0) {
        throw new Error(`Preset not found: ${id}`);
      }
      return
    } catch (e) {
      log.error(`Error deleting preset id: ${id}`, e)
      throw new Error(`Error deleting preset id: ${id}`)
    }
  }
}

View on GitHub (pinned to 4e3e03e322)

Solutions

  1. Check the application log for the underlying error logged as 'Error updating preset id: <id>' with the cause
  2. Verify the preset id exists before updating
  3. Validate that updateValues.config serializes cleanly (JSON.stringify test)
  4. Run migrations / confirm the appdb schema matches the current entity definitions
Defensive patterns

Strategy: try-catch

Validate before calling

const exists = !!(await FormatterPreset.findOne({ where: { id } }))
if (!exists) throw new Error(`Preset ${id} does not exist`)
try { JSON.stringify(updateValues.config) } catch { throw new Error('config is not serializable') }

Try / catch

try {
  await FormatterPreset.updatePreset(id, updateValues)
} catch (e) {
  if (e.message.startsWith(`Error updating preset id: ${id}`)) {
    // read the log entry for the wrapped cause: not-found vs save failure
    console.error(`updatePreset(${id}) failed; check app log for cause`)
  } else throw e
}

Prevention

When it happens

Trigger: Calling updatePreset with a nonexistent id (the inner 'Preset not found' error gets re-wrapped), or a save failure: invalid config shape, DB locked, schema mismatch, constraint violation on save().

Common situations: Stale preset id after deletion; SQLite file locked during save; config value that breaks JSON round-tripping; schema drift after an app upgrade.

Related errors


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