redis/jedis · error · IllegalArgumentException

start, end and count must be set.

Error message

start, end and count must be set.

What it means

XPendingParams.addParams() serializes XPENDING options and requires count to have been set; Jedis throws this IllegalArgumentException when count is null because the Redis XPENDING extended form requires a COUNT argument, with START/END defaulting to the full range if absent.

Solutions

  1. Call .count(n) on the XPendingParams, e.g. new XPendingParams().count(10).
  2. Use the simpler xpending overload or XPendingParams.count(start, end, count) helper so all three are set.
  3. Set start/end explicitly too if you need a bounded range rather than the implicit ('-', '+') defaults.

Example fix

// before
XPendingParams params = new XPendingParams().idle(60000);
jedis.xpending("mystream", "mygroup", params);
// after
XPendingParams params = new XPendingParams().idle(60000).count(10);
jedis.xpending("mystream", "mygroup", params);
Defensive patterns

Strategy: validation

Validate before calling

XPendingParams params = new XPendingParams();
if (paramsGetCount(params) == null) params = new XPendingParams().count(10); // always set count before use

Try / catch

try {
  return jedis.xpending(stream, group, params);
} catch (IllegalArgumentException e) {
  return jedis.xpending(stream, group, new XPendingParams().count(10));
}

Prevention

When it happens

Trigger: Calling XPendingParams with an idle filter or consumer but never calling count(n), then passing it to xpending(range, params) / xpending(key, group, params).

Common situations: Building XPendingParams to filter by idle time or consumer name assuming start/end/count are optional; forgetting that count is mandatory even when defaults for start/end are auto-filled.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/56e5c619adaaed83. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/params/XPendingParams.java:93

  public XPendingParams count(int count) {
    this.count = count;
    return this;
  }

  public XPendingParams consumer(String consumer) {
    this.consumer = from(consumer);
    return this;
  }

  public XPendingParams consumer(byte[] consumer) {
    this.consumer = from(consumer);
    return this;
  }

  @Override
  public void addParams(CommandArguments args) {
    if (count == null) {
      throw new IllegalArgumentException("start, end and count must be set.");
    }
    if (start == null) start = from("-");
    if (end == null) end = from("+");

    if (idle != null) {
      args.add(Keyword.IDLE).add(idle);
    }

    args.add(start).add(end).add(count);

    if (consumer != null) {
      args.add(consumer);
    }
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;

View on GitHub (pinned to 6dac31d4c2)