{"record":{"id":"8047ada6850fcfa2","repo":"eclipse-vertx/vert.x","slug":"invalid-step","errorCode":null,"errorMessage":"Invalid step","messagePattern":"Invalid step","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/internal/CloseSequence.java","lineNumber":65,"sourceCode":"    this.steps = steps;\n    this.current = sequence.length;\n    this.idx = sequence.length;\n  }\n\n  public synchronized boolean started() {\n    return idx < sequence.length;\n  }\n\n  /**\n   * Advance the sequence to the specified {@code step}.\n   *\n   * @param step the target step\n   * @return the future completed upon step completion\n   * @throws IllegalArgumentException when the {@code step} falls out of the actual range\n   */\n  public Future<Void> progressTo(int step) {\n    if (step < 0 || step > steps.size() - 1) {\n      throw new IllegalArgumentException(\"Invalid step\");\n    }\n    boolean checkProgress;\n    synchronized (this) {\n      if (step < idx) {\n        checkProgress = idx == current;\n        idx = step;\n      } else {\n        checkProgress = false;\n      }\n    }\n    if (checkProgress) {\n      tryProgress();\n    }\n    return steps.get(step).future();\n  }\n\n  private void tryProgress() {\n    int curr;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/internal/CloseSequence.java#L47-L83","documentation":"progressTo(step) moves the CloseSequence to a target step index, which must fall within [0, steps.size()-1]. Passing an index outside that range is rejected with IllegalArgumentException(\"Invalid step\"), as documented by the method's @throws clause.","triggerScenarios":"Calling progressTo with a negative step, a step equal to the number of steps, or an index computed against a different/larger sequence than the one constructed.","commonSituations":"External orchestrators (e.g. Vertx close logic) computing the final step as steps.length instead of steps.length-1; reuse of a hardcoded index after the sequence definition changed.","solutions":["Use an index in the range 0..(number of Closeables - 1)","Compute the last step as sequence.length - 1, not sequence.length","Re-derive indices from the actual Closeable[] passed to the constructor rather than hardcoding"],"exampleFix":"// before\nseq.progressTo(steps.length); // out of range, throws\n// after\nseq.progressTo(steps.length - 1);","handlingStrategy":"validation","validationCode":"int stepCount = closables.length;\nif (step < 0 || step >= stepCount) {\n  throw new IllegalArgumentException(\"step must be in [0, \" + (stepCount - 1) + \"]\");\n}\nseq.progressTo(step);","typeGuard":null,"tryCatchPattern":"try {\n  seq.progressTo(step);\n} catch (IllegalArgumentException e) {\n  log.error(\"Invalid close step \" + step + \" for sequence of size \" + closables.length);\n}","preventionTips":["Derive indices from the actual Closeable array, never hardcode","Remember last valid index is length - 1","Recheck indices after modifying the sequence definition"],"tags":["closeable","step-index","out-of-range"],"backgroundTag":"index-out-of-range","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}