{"record":{"id":"bcf17c999cd9defb","repo":"apache/pulsar","slug":"either-timestamp-time-or-position-position","errorCode":null,"errorMessage":"Either Timestamp (--time) or Position (--position) has to be provided to reset cursor","messagePattern":"Either Timestamp \\(--time\\) or Position \\(--position\\) has to be provided to reset cursor","errorType":"validation","errorClass":"PulsarAdminException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdPersistentTopics.java","lineNumber":551,"sourceCode":"                converter = TimeUnitToMillisConverter.class)\n        private Long resetTimeInMillis = null;\n\n        @Option(names = { \"--messageId\",\n                \"-m\" }, description = \"messageId to reset back to (ledgerId:entryId)\", required = false)\n        private String resetMessageIdStr;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String persistentTopic = validatePersistentTopic(topicName);\n            if (isNotBlank(resetMessageIdStr)) {\n                MessageId messageId = validateMessageIdString(resetMessageIdStr);\n                getPersistentTopics().resetCursor(persistentTopic, subName, messageId);\n            } else if (Objects.nonNull(resetTimeInMillis)) {\n                // now - go back time\n                long timestamp = System.currentTimeMillis() - resetTimeInMillis;\n                getPersistentTopics().resetCursor(persistentTopic, subName, timestamp);\n            } else {\n                throw new PulsarAdminException(\n                        \"Either Timestamp (--time) or Position (--position) has to be provided to reset cursor\");\n            }\n        }\n    }\n\n    @Command(description = \"Terminate a topic and don't allow any more messages to be published\")\n    private class Terminate extends CliCommand {\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topicName;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String persistentTopic = validatePersistentTopic(topicName);\n\n            try {\n                MessageId lastMessageId = getPersistentTopics().terminateTopicAsync(persistentTopic).get();\n                System.out.println(\"Topic successfully terminated at \" + lastMessageId);\n            } catch (InterruptedException | ExecutionException e) {","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdPersistentTopics.java#L533-L569","documentation":"`pulsar-admin topics reset-cursor` needs a reset target: either --position (a message id) or --time (a relative offset in ms). If neither option was supplied, the command throws a PulsarAdminException instead of guessing a default reset point.","triggerScenarios":"Running the reset-cursor command with only the topic and subscription name, leaving both --position and --time unset.","commonSituations":"Interactive run where the user assumes default behavior of resetting to earliest/latest; automation scripts where a variable holding --time or --position was empty; confusing reset-cursor with the separate `expire-messages` command.","solutions":["Pass --time with a duration in milliseconds/seconds/unit to reset to now-minus-duration, e.g. --time 1h","Or pass --position with a message id (e.g. ledgerId:entryId or earliest/latest where supported)","Fix script variables so one of the two flags is actually populated"],"exampleFix":"// before\npulsar-admin topics reset-cursor persistent://t/n/topic -s my-sub\n// after\npulsar-admin topics reset-cursor persistent://t/n/topic -s my-sub --time 1h","handlingStrategy":"validation","validationCode":"if (resetTime == null && resetPosition == null) {\n    throw new IllegalArgumentException(\"Provide either --time or --position to reset a cursor\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    persistentTopics.resetCursor(topic, subName, timestampOrMessageId);\n} catch (org.apache.pulsar.client.admin.PulsarAdminException e) {\n    // prompt for missing --time/--position\n}","preventionTips":["Always decide a reset target (time or position) before running reset-cursor","Guard scripts so unset variables don't silently drop flags","Remember expire-messages is a different command with different requirements"],"tags":["cli","cursor","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}