{"record":{"id":"af65885cfda07f50","repo":"tursodatabase/turso","slug":"step-returned-invalid-result-laststepresult","errorCode":null,"errorMessage":"step() returned invalid result: \" + lastStepResult","messagePattern":"step\\(\\) returned invalid result: \" \\+ lastStepResult","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"bindings/java/src/main/java/tech/turso/core/TursoResultSet.java","lineNumber":97,"sourceCode":"    }\n\n    if (maxRows != 0 && row == maxRows) {\n      return false;\n    }\n\n    lastStepResult = this.statement.step();\n    log.debug(\"lastStepResult: {}\", lastStepResult);\n    if (lastStepResult.isRow()) {\n      row++;\n    }\n\n    if (lastStepResult.isInInvalidState()) {\n      open = false;\n      String errorMessage = lastStepResult.getErrorMessage();\n      if (errorMessage != null && !errorMessage.isEmpty()) {\n        throw new SQLException(\"step() returned invalid result: \" + errorMessage);\n      } else {\n        throw new SQLException(\"step() returned invalid result: \" + lastStepResult);\n      }\n    }\n\n    pastLastRow = lastStepResult.isDone();\n    if (pastLastRow && row == 0) {\n      isEmptyResultSet = true;\n    }\n    return !pastLastRow;\n  }\n\n  /** Checks whether the last step result has returned row result. */\n  public boolean hasLastStepReturnedRow() {\n    return lastStepResult != null && lastStepResult.isRow();\n  }\n\n  /** Checks whether the cursor is positioned after the last row. */\n  public boolean isPastLastRow() {\n    return pastLastRow;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/java/src/main/java/tech/turso/core/TursoResultSet.java#L79-L115","documentation":"Same invalid-step-state path as its sibling, but the native result carried no error message (null or empty), so the TursoStepResult's toString is embedded instead. It is the low-information variant: the native side reported failure without text. Debug logging ('lastStepResult: {}') is the only built-in visibility into the state.","triggerScenarios":"A step that enters an invalid state whose TursoStepResult has a null/empty error message — native failure paths that do not populate the message field (some interrupt, busy, or internal error states).","commonSituations":"Intermittent failures in CI that only show 'step() returned invalid result: STEP_RESULT_ID_IO/...' with no SQL text; reproducing locally works because the failure depends on timing or concurrency.","solutions":["Enable DEBUG logging for tech.turso.core.TursoResultSet to capture the full lastStepResult state at each step","Wrap the SQL and the failing step index into your own error context so the repro is actionable","Check for concurrency on the connection (other threads stepping/closing) and for interrupt() usage","If reproducible, minimize the SQL and report it — a message-less invalid state is a native diagnostics gap"],"exampleFix":"// before\nwhile (rs.next()) { emit(rs); } // 'step() returned invalid result: TursoStepResult@...'\n\n// after\ntry {\n  while (rs.next()) { emit(rs); }\n} catch (SQLException e) {\n  throw new IllegalStateException(\"query failed: \" + sql, e); // keep SQL + result context\n}\n// plus run with: -Djava.util.logging.level=FINE (or SLF4J debug for tech.turso.core)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  while (rs.next()) {\n    emit(rs);\n  }\n} catch (SQLException e) {\n  // no native message in this variant — capture lastStepResult via debug logs\n  // and attach the SQL + step index to whatever error you rethrow\n  throw new IllegalStateException(\"step failed for query: \" + sql, e);\n}","preventionTips":["Run with DEBUG logging for tech.turso.core.TursoResultSet in environments where the failure occurs","Always attach the SQL to iteration errors — this variant carries no native text","Check for concurrent use of the statement/connection when it appears intermittently"],"tags":["java","jdbc","resultset","step","native","diagnostics","bindings"],"backgroundTag":"sql-execution-runtime-error","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}