t8y2/dbx · error · IllegalArgumentException

Unsupported reset position: " + position

Error message

Unsupported reset position: " + position

What it means

position must be one of "earliest", "latest", "" (treated as latest), or "timestamp" after trim/lowercase. Any other string hits the switch default and throws IllegalArgumentException "Unsupported reset position: <position>" (KafkaAgent.java:1573).

Source

Thrown at agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java:1573

            }
            return decimal.longValueExact();
        } catch (ArithmeticException error) {
            throw new IllegalArgumentException(name + " is outside the supported integer range", error);
        }
    }

    static OffsetSpec offsetSpecForPosition(String position, Long timestampMs) {
        String normalized = position == null ? "latest" : position.trim().toLowerCase(Locale.ROOT);
        return switch (normalized) {
            case "earliest" -> OffsetSpec.earliest();
            case "latest", "" -> OffsetSpec.latest();
            case "timestamp" -> {
                if (timestampMs == null) {
                    throw new IllegalArgumentException("timestampMs is required when position is timestamp");
                }
                yield OffsetSpec.forTimestamp(timestampMs);
            }
            default -> throw new IllegalArgumentException("Unsupported reset position: " + position);
        };
    }

    // -----------------------------------------------------------------------
    // Messages
    // -----------------------------------------------------------------------

    private static Object peekMessages(JsonObject params) throws Exception {
        String topic = stringOrEmpty(params, "topic");
        Integer partition = integerOrNull(params, "partition");
        Long offset = longOrNull(params, "offset");
        int count = validatedPeekCount(intOrDefault(params, "count", 10));
        PeekStartPosition startPosition = peekStartPosition(params);
        boolean explicitStartPosition = stringOrNull(params, "startPosition") != null;
        validatePeekRequest(startPosition, explicitStartPosition, partition, offset);
        boolean legacyOffsetRequest = !explicitStartPosition && offset != null;

        JsonObject conn = activeConnection;

View on GitHub (pinned to c0390bff16)

Solutions

  1. Use exactly "earliest", "latest", or "timestamp" for position
  2. Map alternative vocabularies (beginning->earliest, end->latest) before calling
  3. Normalize and whitelist the position value in your config layer

Example fix

// before
params.put("position", "beginning");
// after
params.put("position", "earliest");
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = ['earliest','latest','timestamp','']; if (!ALLOWED.includes(String(position ?? '').trim().toLowerCase())) throw new Error('unsupported position');

Type guard

function isPosition(p){ return ['earliest','latest','timestamp',''].includes(String(p ?? '').trim().toLowerCase()); }

Try / catch

try { agent.execute(req); } catch (e) { if (String(e.message).startsWith('Unsupported reset position')) { /* map to allowed keyword */ } else throw e; }

Prevention

When it happens

Trigger: Passing position values like "beginning", "end", "Earliest " (untrimmed is trimmed actually), "oldest", "newest", or misspelled values.

Common situations: Migrating from another tool whose keywords are "beginning"/"end"; user-supplied CLI/config values not validated before reaching the agent.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/231dc1b23fc3d59a. Report an issue: GitHub.