# sqlalchemy.exc.ArgumentError: relationship 'User.posts' expects a class or a mapper argument (received: <class 'str'>)

- **ID:** `python/sqlalchemy-invalid-relationship-argument`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Passing a string to relationship() without proper string resolution context, e.g., using a non-existent class name.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.4.x | active | — | — |
| 2.0.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Ensure the class is defined before the relationship: class Post(Base): ...; class User(Base): posts = relationship(Post)
   ```
2. **** (85% success)
   ```
   Use string with full module path if using declarative: posts = relationship('myapp.models.Post')
   ```

## Dead Ends

- **** — If the class is not yet defined, it will raise NameError. (80% fail)
- **** — NameError occurs because the class is not in scope. (90% fail)
