# sqlalchemy.exc.AmbiguousForeignKeysError: Could not determine join condition between parent/child tables on relationship User.addresses - there are multiple foreign key paths linking the tables. Specify the 'foreign_keys' argument.

- **ID:** `python/sqlalchemy-ambiguous-foreign-key`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Multiple foreign keys between two tables without explicit join condition.

## Version Compatibility

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

## Workarounds

1. **Specify 'foreign_keys' argument in relationship.** (95% success)
   ```
   class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    addresses = relationship('Address', foreign_keys='Address.user_id')
   ```
2. **Use primaryjoin explicitly.** (90% success)
   ```
   addresses = relationship('Address', primaryjoin='User.id == Address.user_id')
   ```

## Dead Ends

- **Removing one foreign key constraint from the database.** — Destructive and may break data integrity; not necessary. (50% fail)
- **Setting primaryjoin with a string that doesn't match columns.** — String must be a valid SQL expression; typos cause errors. (70% fail)
