# FailedPreconditionError: GetNext() failed because the iterator has not been initialized

- **ID:** `tensorflow/iterator-get-next-failed-precondition`
- **Domain:** tensorflow
- **Category:** runtime_error
- **Error Code:** `FPRECOND`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A tf.data iterator was used without being initialized, typically in TF1 style code or when using tf.compat.v1.data.make_one_shot_iterator incorrectly.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| tensorflow 2.10 | active | — | — |
| tensorflow 2.11 | active | — | — |
| tensorflow 2.12 | active | — | — |

## Workarounds

1. **Initialize the iterator explicitly before fetching: iterator = dataset.make_initializable_iterator(); sess.run(iterator.initializer); then sess.run(get_next).** (90% success)
   ```
   Initialize the iterator explicitly before fetching: iterator = dataset.make_initializable_iterator(); sess.run(iterator.initializer); then sess.run(get_next).
   ```
2. **Switch to TF2-style eager iteration: for batch in dataset: ... instead of using iterators.** (95% success)
   ```
   Switch to TF2-style eager iteration: for batch in dataset: ... instead of using iterators.
   ```

## Dead Ends

- **** — The iterator still lacks initialization; only a fresh session restart is attempted. (95% fail)
- **** — The initialization must happen before any get_next call, not after. (85% fail)
