# pydantic_core._pydantic_core.ValidationError: 1 validation error for UserOut
id
  Input should be a valid integer [type=int_type, input_value=<sqlalchemy.orm.attributes.InstrumentedAttribute object>, input_type=InstrumentedAttribute]

- **ID:** `python/pydantic-orm-mode-from-attributes`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Passing a SQLAlchemy model class (not an instance) to model_validate, or from_attributes not enabled so Pydantic reads the class attribute instead of the instance.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   from pydantic import BaseModel, ConfigDict
class UserOut(BaseModel):
    model_config = ConfigDict(from_attributes=True)
    id: int
    name: str

UserOut.model_validate(db_user)  # db_user is a SQLAlchemy instance
   ```
2. **** (85% success)
   ```
   UserOut(id=db_user.id, name=db_user.name)
   ```

## Dead Ends

- **** — SQLAlchemy instances store state in _sa_instance_state; __dict__ includes internal keys and misses lazy relations. (60% fail)
- **** — You're validating the class, not an instance; attributes are InstrumentedAttribute descriptors. (70% fail)
- **** — In Pydantic v2 this raises a deprecation warning and is ignored unless from_attributes is set. (55% fail)
