{"record":{"id":"afa7ead4252a8c69","repo":"apache/seatunnel","slug":"write-operations-require-yes-or-use-dry-run","errorCode":null,"errorMessage":"Write operations require --yes (or use --dry-run)","messagePattern":"Write operations require --yes \\(or use --dry-run\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-edge-agent/seatunnel-edge-agent-starter/src/main/java/org/apache/seatunnel/edge/agent/starter/command/db/DbWriteGuard.java","lineNumber":35,"sourceCode":"\npackage org.apache.seatunnel.edge.agent.starter.command.db;\n\nimport org.apache.seatunnel.edge.agent.starter.command.EdgeAgentPaths;\n\nimport java.io.IOException;\n\npublic class DbWriteGuard {\n\n    public static void requireWriteAllowed(EdgeAgentPaths paths, DbCommandArgs cli)\n            throws IOException {\n        if (!cli.isDryRun() && paths.agentRunning()) {\n            throw new IllegalStateException(\n                    \"Agent is running (pid file \"\n                            + paths.getPidFile()\n                            + \"); stop the agent before write operations.\");\n        }\n        if (!cli.isDryRun() && !cli.isYes()) {\n            throw new IllegalArgumentException(\"Write operations require --yes (or use --dry-run)\");\n        }\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":39,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-edge-agent/seatunnel-edge-agent-starter/src/main/java/org/apache/seatunnel/edge/agent/starter/command/db/DbWriteGuard.java#L17-L39","documentation":"DbWriteGuard.requireWriteAllowed blocks any agent DB write operation unless the CLI was invoked with explicit confirmation. A write command is allowed only when --yes is passed (explicit intent) or --dry-run is used (no mutation). The exception is thrown as IllegalArgumentException before any DB connection is opened.","triggerScenarios":"Running a mutating wal subcommand (wal-purge-acked, wal-retry-dead, wal-purge-dead, wal-unstick-sending) without either --yes or --dry-run flags.","commonSituations":"Users run wal-purge-acked in CI/scripts and forget the confirmation flag; interactive users type commands from docs without the safety flag; scripts written before the guard was introduced now fail.","solutions":["Re-run with --dry-run first to preview affected rows, then re-run with --yes to apply.","If you only want a report, add --dry-run so the guard is satisfied without writing.","Stop the agent first if the pid-file check also fires, then re-run with --yes.","Update your scripts to pass --yes explicitly, never default it silently."],"exampleFix":"// before\nagent db wal-purge-acked --older-than-ms 86400000\n// after\nagent db wal-purge-acked --older-than-ms 86400000 --yes\n// or preview first\nagent db wal-purge-acked --older-than-ms 86400000 --dry-run","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2);\nconst isWriteCmd = /^(wal-purge-acked|wal-purge-dead|wal-retry-dead|wal-unstick-sending)$/.test(args[0]);\nif (isWriteCmd && !args.includes('--yes') && !args.includes('--dry-run')) {\n  throw new Error('Refusing to run write command without --yes or --dry-run');\n}","typeGuard":null,"tryCatchPattern":"try {\n  runAgentDbCommand(args);\n} catch (e) {\n  if (String(e.message).includes('--yes')) {\n    console.error('Confirmation required: re-run with --dry-run to preview, then --yes to apply.');\n  }\n}","preventionTips":["Always run --dry-run first to preview affected rows before any --yes invocation.","Never hardcode --yes in shared scripts without an operator confirmation step.","Stop the agent (check the pid-file) before write commands so the guard's other check does not fire."],"tags":["cli","safety-guard","write-operations","confirmation"],"backgroundTag":"missing-required-flag","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}