Skip to content

Fix: Cast LazyString to str before DB commit#97

Open
jilkka wants to merge 1 commit intodannymcc:mainfrom
jilkka:main
Open

Fix: Cast LazyString to str before DB commit#97
jilkka wants to merge 1 commit intodannymcc:mainfrom
jilkka:main

Conversation

@jilkka
Copy link
Copy Markdown

@jilkka jilkka commented Mar 1, 2026

Added force_string validator to ensure label is string before DB commit.

Summary

Fixed a 500 Internal Server Error occurring when adding vehicle specifications during new vehicle creation and adding to existing vehicle.
LazyStrings were being passed directly to SQLite resulting in crash.

Changelog

  • Added: A @validates decorator in models.py to automatically cast specification labels to standard strings before they reach the database.

  • Fixed: sqlalchemy.exc.ProgrammingError when saving predefined vehicle spec types during new vehicle creation and after.

Testing

How were these changes tested?

  • Tested locally
  • Tested with Docker image

Added force_string validator to ensure label is string before DB commit.
@lyonsden69
Copy link
Copy Markdown

I can confirm this is still happening on v0.15.0 using the Docker image on a Synology NAS.

What I found:

  • Adding preset vehicle specs causes a 500 error
  • Adding custom specs works normally
  • The entered value does not seem to matter

Relevant log output:
sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) Error binding parameter 3: type 'LazyString' is not supported
[SQL: INSERT INTO vehicle_specs (vehicle_id, spec_type, label, value, created_at) VALUES (?, ?, ?, ?, ?) RETURNING id]
[parameters: (1, 'tire_size_front', l'Front Tire Size', '225/65/R17', '2026-03-13 16:25:15.342948')]

Thanks for the fix in PR #97 — happy to test once it makes it into a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants