Skip to content

Commit 9bc772b

Browse files
zyw02steipeteampagent
authored
fix(cron): mutex blank --model/--thinking with matching clear flags (#119894)
* fix(cron): reject blank --model/--thinking on cron edit Empty Commander values skipped the clear-* mutex after normalize, so --model '' --clear-model still cleared the override. Align with fallbacks and delivery clear presence checks. Co-authored-by: Peter Steinberger <[email protected]> * test(cron): align empty model/thinking edit expectation with blank reject The legacy cron-cli suite still expected blank --model/--thinking to be omitted; that contradicts the fail-closed blank validation and broke CI. Co-authored-by: Peter Steinberger <[email protected]> * fix(cron): mutex blank --model/--thinking with matching clear flags Standalone blank overrides stay omitted. Flag presence now conflicts with --clear-model/--clear-thinking instead of silently applying the clear. Co-authored-by: Peter Steinberger <[email protected]> * test(cron): focus blank clear mutex coverage Amp-Thread-ID: https://ampcode.com/threads/T-01a0220d-eaa0-76b4-adb9-68841f015b75 --------- Co-authored-by: zyw02 <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Amp <[email protected]>
1 parent 371f8ce commit 9bc772b

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎src/cli/cron-cli/register.cron-edit-options.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ export async function resolveCronEditPayloadDeliveryPatch(
3333
if (commandShell && commandArgv) {
3434
throw new Error("Pass command payload either with --command or --command-argv, not both.");
3535
}
36+
// Raw flag presence owns the set/clear mutex even when normalization omits a blank value.
37+
const hasModel = typeof opts.model === "string";
3638
const model = normalizeOptionalString(opts.model);
37-
if (model && opts.clearModel) {
39+
if (hasModel && opts.clearModel) {
3840
throw new Error("Use --model or --clear-model, not both");
3941
}
42+
const hasThinking = typeof opts.thinking === "string";
4043
const thinking = normalizeOptionalString(opts.thinking);
41-
if (thinking && opts.clearThinking) {
44+
if (hasThinking && opts.clearThinking) {
4245
throw new Error("Use --thinking or --clear-thinking, not both");
4346
}
4447
const fallbacks = parseCronFallbacks(opts.fallbacks);

‎src/cli/cron-cli/register.cron-edit.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,18 @@ describe("cron edit command", () => {
698698
);
699699
});
700700

701+
it.each([
702+
["--model", "", "--clear-model"],
703+
["--model", " ", "--clear-model"],
704+
["--thinking", "", "--clear-thinking"],
705+
["--thinking", " ", "--clear-thinking"],
706+
])("rejects blank %s %j combined with %s", async (flag, value, clearFlag) => {
707+
await expectCronEditRejection(
708+
[flag, value, clearFlag],
709+
`Use ${flag} or ${clearFlag}, not both`,
710+
);
711+
});
712+
701713
it("stores an explicit wildcard with --clear-tools", async () => {
702714
callGatewayFromCli.mockImplementation(async (method: string) => {
703715
if (method === "cron.get") {

0 commit comments

Comments
 (0)