apache/beam · error · NoSuchElementException
No current record (Indicates misuse. Perhaps advance() was…
Error message
No current record (Indicates misuse. Perhaps advance() was not called?)
What it means
KuduServiceImpl's reader Avantor/function getCurrent() returns the parsed current record; if advance() was never called (or the iterator is exhausted and getCurrent is invoked again), 'current' is null and a NoSuchElementException is thrown indicating API misuse of the reader.
Solutions
- Always call advance() first and only call getCurrent() after it returned true
- Stop iterating when advance() returns false instead of reading getCurrent() again
- Wrap reader consumption in the standard pattern: while (reader.advance()) { T item = reader.getCurrent(); ... }
Example fix
// before
T item = reader.getCurrent(); // NoSuchElementException
// after
if (reader.advance()) {
T item = reader.getCurrent();
} Defensive patterns
Strategy: type-guard
Validate before calling
boolean readable = reader.advance();
if (!readable) { return; } // nothing to read Type guard
static <T> java.util.Optional<T> nextRecord(KuduServiceImpl.Reader<T> reader) {
return reader.advance()
? java.util.Optional.of(reader.getCurrent())
: java.util.Optional.empty();
} Try / catch
try {
T item = reader.getCurrent();
} catch (NoSuchElementException e) {
// misuse: ensure advance() called and returned true before getCurrent()
} Prevention
- Follow the standard iterator protocol: advance() then getCurrent()
- Never call getCurrent() after advance() returned false
- Encapsulate reader iteration in a helper method to enforce the protocol
When it happens
Trigger: Calling getCurrent() on a KuduIO reader before any advance() call, or calling getCurrent() after advance() returned false (iterator exhausted).
Common situations: Custom Beam source consumers iterating a KuduSource reader incorrectly; wrapping the reader in code that assumes getCurrent() is valid without tracking advance()'s return value.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- At least " + session.countPendingErrors() + " error(s)…
- Unable to infer coder for output of parseFn (" +…
- A function must be provided to convert the input type into…
- A PValue contained in
- A schema was provided without a data format (or viceversa)…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8152280ddb59dff8.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/kudu/src/main/java/org/apache/beam/sdk/io/kudu/KuduServiceImpl.java:179
scanner = builder.build();
}
return advance();
}
/**
* Returns the current record transformed into the desired type.
*
* @return the current record
* @throws NoSuchElementException If the current does not exist
*/
@Override
public T getCurrent() throws NoSuchElementException {
if (current != null) {
return source.spec.getParseFn().apply(current);
} else {
throw new NoSuchElementException(
"No current record (Indicates misuse. Perhaps advance() was not called?)");
}
}
@Override
public boolean advance() throws KuduException {
// scanner pages over results, with each page holding an iterator of records
if (iter == null || (!iter.hasNext() && scanner.hasMoreRows())) {
iter = scanner.nextRows();
}
if (iter != null && iter.hasNext()) {
current = iter.next();
++recordsReturned;
return true;
}
return false;View on GitHub (pinned to 12126d8942)