fix: resolve frontend/backend integration bugs
- Rename skincare route prefix /skin-snapshots → /skincare to match API client - Add redirect_slashes=False to FastAPI app; change collection routes from "/" to "" to eliminate 307 redirects on POST/GET without trailing slash - Fix redirect() inside try/catch in products/new and routines/new server actions (SvelteKit redirect() throws and was being caught as a 500 error) - Eagerly load inventory and steps relationships via explicit SELECT + model_dump(mode="json"), working around SQLModel 0.0.37 not serializing Relationship fields in response_model - Add field_validator for product_effect_profile to coerce DB-returned dict → ProductEffectProfile, eliminating Pydantic serializer warning - Update all tests to use routes without trailing slash Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8d4f9d1fc6
commit
9bf94a979c
11 changed files with 85 additions and 68 deletions
|
|
@ -2,7 +2,7 @@ from datetime import date, datetime
|
|||
from typing import ClassVar, Optional
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from pydantic import model_validator
|
||||
from pydantic import field_validator, model_validator
|
||||
from sqlalchemy import JSON, Column, DateTime
|
||||
from sqlmodel import Field, Relationship, SQLModel
|
||||
|
||||
|
|
@ -188,6 +188,13 @@ class Product(SQLModel, table=True):
|
|||
|
||||
inventory: list["ProductInventory"] = Relationship(back_populates="product")
|
||||
|
||||
@field_validator("product_effect_profile", mode="before")
|
||||
@classmethod
|
||||
def coerce_effect_profile(cls, v: object) -> object:
|
||||
if isinstance(v, dict):
|
||||
return ProductEffectProfile(**v)
|
||||
return v
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_business_rules(self) -> "Product":
|
||||
if (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue