{"record":{"id":"231dc1b23fc3d59a","repo":"t8y2/dbx","slug":"unsupported-reset-position-position","errorCode":null,"errorMessage":"Unsupported reset position: \" + position","messagePattern":"Unsupported reset position: \" \\+ position","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java","lineNumber":1573,"sourceCode":"            }\n            return decimal.longValueExact();\n        } catch (ArithmeticException error) {\n            throw new IllegalArgumentException(name + \" is outside the supported integer range\", error);\n        }\n    }\n\n    static OffsetSpec offsetSpecForPosition(String position, Long timestampMs) {\n        String normalized = position == null ? \"latest\" : position.trim().toLowerCase(Locale.ROOT);\n        return switch (normalized) {\n            case \"earliest\" -> OffsetSpec.earliest();\n            case \"latest\", \"\" -> OffsetSpec.latest();\n            case \"timestamp\" -> {\n                if (timestampMs == null) {\n                    throw new IllegalArgumentException(\"timestampMs is required when position is timestamp\");\n                }\n                yield OffsetSpec.forTimestamp(timestampMs);\n            }\n            default -> throw new IllegalArgumentException(\"Unsupported reset position: \" + position);\n        };\n    }\n\n    // -----------------------------------------------------------------------\n    // Messages\n    // -----------------------------------------------------------------------\n\n    private static Object peekMessages(JsonObject params) throws Exception {\n        String topic = stringOrEmpty(params, \"topic\");\n        Integer partition = integerOrNull(params, \"partition\");\n        Long offset = longOrNull(params, \"offset\");\n        int count = validatedPeekCount(intOrDefault(params, \"count\", 10));\n        PeekStartPosition startPosition = peekStartPosition(params);\n        boolean explicitStartPosition = stringOrNull(params, \"startPosition\") != null;\n        validatePeekRequest(startPosition, explicitStartPosition, partition, offset);\n        boolean legacyOffsetRequest = !explicitStartPosition && offset != null;\n\n        JsonObject conn = activeConnection;","sourceCodeStart":1555,"sourceCodeEnd":1591,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java#L1555-L1591","documentation":"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).","triggerScenarios":"Passing position values like \"beginning\", \"end\", \"Earliest \" (untrimmed is trimmed actually), \"oldest\", \"newest\", or misspelled values.","commonSituations":"Migrating from another tool whose keywords are \"beginning\"/\"end\"; user-supplied CLI/config values not validated before reaching the agent.","solutions":["Use exactly \"earliest\", \"latest\", or \"timestamp\" for position","Map alternative vocabularies (beginning->earliest, end->latest) before calling","Normalize and whitelist the position value in your config layer"],"exampleFix":"// before\nparams.put(\"position\", \"beginning\");\n// after\nparams.put(\"position\", \"earliest\");","handlingStrategy":"validation","validationCode":"const ALLOWED = ['earliest','latest','timestamp','']; if (!ALLOWED.includes(String(position ?? '').trim().toLowerCase())) throw new Error('unsupported position');","typeGuard":"function isPosition(p){ return ['earliest','latest','timestamp',''].includes(String(p ?? '').trim().toLowerCase()); }","tryCatchPattern":"try { agent.execute(req); } catch (e) { if (String(e.message).startsWith('Unsupported reset position')) { /* map to allowed keyword */ } else throw e; }","preventionTips":["Whitelist position values at the config/CLI layer","Map synonyms (beginning->earliest, end->latest) before calling","Keep position keywords in a shared constant list"],"tags":["kafka","input-validation","enum-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}