jackwener/OpenCLI · error · CommandExecutionError

定时设置未验证成功: expected=

Error message

定时设置未验证成功: expected=${expected} actual=${result.value || ''}

What it means

After setScheduleTime fills the schedule picker, it verifies the picker's displayed value contains the expected 'YYYY-MM-DD HH:mm' string. If the displayed value differs, it throws CommandExecutionError, meaning the schedule was applied but the confirmation readback does not match the requested time.

Solutions

  1. Log the actual result.value to see how the site formatted the time
  2. Check the requested time is valid and not auto-corrected by the site (past time, rounded minutes)
  3. Adjust the expected format or comparison to match current site output format
  4. Take a manual look at the page (or screenshot) to confirm whether the schedule actually took effect

Example fix

// before
if (!String(result.value || '').includes(expected)) {
  throw new CommandExecutionError(`定时设置未验证成功: expected=${expected} actual=${result.value || ''}`);
}
// after
const normalized = String(result.value || '').replace(/\s+/g, ' ').trim();
if (!normalized.includes(expected) && !normalized.includes(expected.replace(/\b0(\d)/g, '$1'))) {
  throw new CommandExecutionError(`定时设置未验证成功: expected=${expected} actual=${normalized}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

const expected = `${y}-${String(mo).padStart(2,'0')}-${String(d).padStart(2,'0')} ${String(h).padStart(2,'0')}:${String(mi).padStart(2,'0')}`;
if (!/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(expected)) throw new Error('Bad schedule format');

Type guard

function isScheduleResult(r) {
  return !!r && typeof r === 'object' && typeof r.value === 'string' && r.value.length > 0;
}

Try / catch

try {
  await setScheduleTime(page, y, mo, d, h, mi);
} catch (e) {
  if (/定时设置未验证成功/.test(e.message)) {
    const actual = e.message.split('actual=')[1];
    console.warn(`Schedule readback mismatch (expected vs actual): ${actual}`); // verify manually before retry
  } else throw e;
}

Prevention

When it happens

Trigger: String(result.value) does not include the expected formatted datetime, e.g. picker zero-padding differs, value was normalized/clamped by the site, or the picker silently ignored one of the fields.

Common situations: Requesting a time that the site rounds (e.g. only minute granularity of 5 allowed); locale-formatted dates; site clamping near-midnight times; DOM readback returning concatenated values in a different format after a frontend update.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/8000658169ca8177. Report an issue: GitHub.

Appendix: source

Thrown at clis/wechat-channels/publish.js:513

      await sleep(300);

      // 6. Read back the display input to confirm the value landed.
      var inp = deepQuery('input[placeholder*="发表时间"]');
      return { ok: true, value: inp ? inp.value : null };
    })(${targetYear}, ${targetMonth}, ${targetDay}, ${targetHour}, ${targetMin})
  `);

  if (!result?.ok) {
    await page.screenshot({ path: '/tmp/wechat-channels_schedule_debug.png' });
    const reason = result?.reason ? String(result.reason) : 'empty picker result';
    throw new CommandExecutionError(
      `定时设置失败 (${reason}),截图: /tmp/wechat-channels_schedule_debug.png`,
    );
  }

  const expected = `${targetYear}-${pad(targetMonth)}-${pad(targetDay)} ${pad(targetHour)}:${pad(targetMin)}`;
  if (!String(result.value || '').includes(expected)) {
    throw new CommandExecutionError(`定时设置未验证成功: expected=${expected} actual=${result.value || ''}`);
  }
  process.stderr.write(`  定时设置完成: ${result.value || expected}\n`);
}

// ── Helper: click publish or draft button ────────────────────────────────────
async function clickPublish(page, isDraft) {
  const labels = isDraft
    ? ['存草稿', '保存草稿', '草稿']
    : ['发表', '发布'];

  const clicked = await evalPage(page, `
    (function(labels) {
      ${DEEP_QUERY_FN}
      var btns = deepQueryAll('button');
      for (var i = 0; i < btns.length; i++) {
        var btn = btns[i];
        var text = (btn.innerText || btn.textContent || '').trim();
        var isDisabled = btn.disabled || btn.getAttribute('disabled') !== null ||

View on GitHub (pinned to 49907e53dc)