# RuntimeError: No response returned

- **ID:** `python/fastapi-dependency-yield-cleanup`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

In FastAPI, a dependency with yield must be used as a generator; if you forget to yield or return, route fails.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   def get_db():
    db = Session()
    try:
        yield db
    finally:
        db.close()

@app.get('/')
def read(db = Depends(get_db)):
    return {'db': db}
   ```
2. **** (85% success)
   ```
   If you need to return, use a regular function without yield.
   ```

## Dead Ends

- **** — FastAPI expects a generator for cleanup; return breaks it. (90% fail)
- **** — Dependency not invoked; no response generated. (70% fail)
