@cryptotaxi247 / CoPilot / commits / 2db3c74e

fix: add from_attributes=True to integration schemas for ORM extraction (#864)

The /api/integrations/customer_integrations/{customer_code} endpoint 500'd on response validation: 8 validation errors for CustomerIntegrationsResponse available_integrations.0 Input should be a valid dictionary or instance of CustomerIntegrations [type=model_type, input_value=CustomerIntegrations(...)] Two distinct classes share the name `CustomerIntegrations`: the SQLModel table in models/customer_integration_settings.py and the Pydantic schema in integrations/schema.py. Routes feed SQLAlchemy ORM rows directly into the Pydantic response. Pydantic 1 extracted attributes leniently; v2 requires explicit `from_attributes=True` (the rename of v1's `orm_mode`). Add `model_config = ConfigDict(from_attributes=True)` to the four schemas in the joinedload chain: IntegrationAuthKeys, IntegrationService, IntegrationSubscription, CustomerIntegrations. Sibling CustomerIntegrationsMetaSchema already had it. Co-authored-by: taylor_socfortress <taylor.walton@socfortress.co> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

taylorcopilot committed May 8, 2026 at 17:29 UTC 2db3c74e4594d7804065bdcef183cd4c9a920bb9
1 file changed +8
backend/app/integrations/schema.py
+8
@@ -150,12 +150,16 @@ class IntegrationAuthKeys(BaseModel):
150 auth_value: str
151 subscription_id: int
152
153 + model_config = ConfigDict(from_attributes=True)
154 +
155
156 class IntegrationService(BaseModel):
157 auth_type: str
158 service_name: str
159 id: int
160
161 + model_config = ConfigDict(from_attributes=True)
162 +
163
164 class IntegrationSubscription(BaseModel):
165 id: int
@@ -164,6 +168,8 @@ class IntegrationSubscription(BaseModel):
168 integration_service: IntegrationService
169 integration_auth_keys: List[IntegrationAuthKeys] # Changed from IntegrationConfig
170
171 + model_config = ConfigDict(from_attributes=True)
172 +
173
174 class CustomerIntegrations(BaseModel):
175 customer_code: str
@@ -186,6 +192,8 @@ class CustomerIntegrations(BaseModel):
192 examples=[True],
193 )
194
195 + model_config = ConfigDict(from_attributes=True)
196 +
197
198 class CustomerIntegrationsResponse(BaseModel):
199 available_integrations: List[CustomerIntegrations]