Skip to content

Commit f22a536

Browse files
committed
fix(cli): preserve doctor session selector errors
1 parent 6594d83 commit f22a536

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎src/cli/program/register.maintenance.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,14 @@ describe("registerMaintenanceCommands doctor action", () => {
231231
expect(runtime.exit).toHaveBeenCalledWith(2);
232232
});
233233

234-
it("rejects session sqlite selectors without session sqlite mode", async () => {
235-
await runMaintenanceCli(["doctor", "--session-sqlite-agent", "main"]);
234+
it.each([
235+
["without JSON", ["--session-sqlite-agent", "main"]],
236+
["with JSON", ["--json", "--session-sqlite-agent", "main"]],
237+
])("rejects session sqlite selectors without session sqlite mode %s", async (_label, args) => {
238+
await runMaintenanceCli(["doctor", ...args]);
236239

237240
expect(doctorCommand).not.toHaveBeenCalled();
241+
expect(runDoctorLintCli).not.toHaveBeenCalled();
238242
expect(runtime.error).toHaveBeenCalledWith(
239243
"doctor session SQLite options require --session-sqlite. Use `openclaw doctor --session-sqlite dry-run ...`.",
240244
);

‎src/cli/program/register.maintenance.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ export function registerMaintenanceCommands(program: Command) {
115115
opts.lint !== true &&
116116
opts.postUpgrade !== true &&
117117
typeof opts.stateSqlite !== "string" &&
118-
typeof opts.sessionSqlite !== "string";
118+
typeof opts.sessionSqlite !== "string" &&
119+
!hasSessionSqliteOnlyDoctorOptions(opts);
119120
if (jsonImpliesLint && (opts.repair === true || opts.fix === true || opts.force === true)) {
120121
defaultRuntime.error(
121122
"doctor --json runs read-only lint checks and cannot be combined with --repair, --fix, or --force.",

0 commit comments

Comments
 (0)