{"record":{"id":"694d2d0a178bbb20","repo":"beekeeper-studio/beekeeper-studio","slug":"error-updating-preset-id-id","errorCode":null,"errorMessage":"Error updating preset id: ${id}","messagePattern":"Error updating preset id: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/studio/src/common/appdb/models/FormatterPreset.ts","lineNumber":94,"sourceCode":"      throw new Error(`Error adding new preset`)\n    }\n  }\n\n  static async updatePreset(id: number, updateValues: FormatterPresetValues): Promise<TransportFormatterPreset>{\n    const existing = await this.findOne({ where: { id } })\n    const { config } = updateValues\n    try {\n      if (!existing) throw new Error('Preset not found')\n      existing.config = JSON.stringify(config)\n      const savedFormat = await existing.save()\n      return {\n        ...savedFormat,\n        config: JSON.parse(savedFormat.config),\n        systemDefault: Boolean(savedFormat.systemDefault)\n      }\n    } catch (e) {\n      log.error(`Error updating preset id: ${id}`, e)\n      throw new Error(`Error updating preset id: ${id}`)\n    }\n  }\n\n  static async deletePreset(id: number): Promise<void> {\n    try {\n      const result = await this.delete(id)\n      if (result.affected === 0) {\n        throw new Error(`Preset not found: ${id}`);\n      }\n      return\n    } catch (e) {\n      log.error(`Error deleting preset id: ${id}`, e)\n      throw new Error(`Error deleting preset id: ${id}`)\n    }\n  }\n}\n","sourceCodeStart":76,"sourceCodeEnd":111,"githubUrl":"https://github.com/beekeeper-studio/beekeeper-studio/blob/4e3e03e3223b2b71a1af8926d455f533b80af837/apps/studio/src/common/appdb/models/FormatterPreset.ts#L76-L111","documentation":"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.","triggerScenarios":"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().","commonSituations":"Stale preset id after deletion; SQLite file locked during save; config value that breaks JSON round-tripping; schema drift after an app upgrade.","solutions":["Check the application log for the underlying error logged as 'Error updating preset id: <id>' with the cause","Verify the preset id exists before updating","Validate that updateValues.config serializes cleanly (JSON.stringify test)","Run migrations / confirm the appdb schema matches the current entity definitions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const exists = !!(await FormatterPreset.findOne({ where: { id } }))\nif (!exists) throw new Error(`Preset ${id} does not exist`)\ntry { JSON.stringify(updateValues.config) } catch { throw new Error('config is not serializable') }","typeGuard":null,"tryCatchPattern":"try {\n  await FormatterPreset.updatePreset(id, updateValues)\n} catch (e) {\n  if (e.message.startsWith(`Error updating preset id: ${id}`)) {\n    // read the log entry for the wrapped cause: not-found vs save failure\n    console.error(`updatePreset(${id}) failed; check app log for cause`)\n  } else throw e\n}","preventionTips":["Check existence before update to disambiguate the wrapped message","Ensure config round-trips through JSON.stringify/JSON.parse before saving","Keep the SQLite appdb accessible (not locked by another process)","Read the paired log.error line — it contains the root-cause error"],"tags":["typeorm","persistence","error-wrapping"],"backgroundTag":"preset-save-failed","analyzedSha":"4e3e03e3223b2b71a1af8926d455f533b80af837","analyzedAt":"2026-08-31T23:21:23.379Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}