jackwener/OpenCLI · error · CommandExecutionError
Gmail ${label} had an invalid timestamp
Error message
Gmail ${label} had an invalid timestamp What it means
gmailDate converts Gmail's numeric timestamps into ISO strings. If the value cannot be coerced into a finite positive number (NaN, 0, negative, or a garbage string), the library throws CommandExecutionError because a valid timestamp is required to build the date. This is the pre-normalization branch of the check.
Source
Thrown at clis/gmail/utils.js:55
}
export function parseAccount(raw) {
const value = raw ?? 0;
const account = Number(value);
if (!Number.isInteger(account) || account < 0 || account > 20) {
throw new ArgumentError('account must be an integer between 0 and 20');
}
return account;
}
function cleanString(value) {
return typeof value === 'string' ? value.trim() : '';
}
function gmailDate(value, label) {
let timestamp = Number(value);
if (!Number.isFinite(timestamp) || timestamp <= 0) {
throw new CommandExecutionError(`Gmail ${label} had an invalid timestamp`);
}
if (timestamp < 10_000_000_000) timestamp *= 1000;
if (timestamp > 10_000_000_000_000) timestamp /= 1000;
const date = new Date(timestamp);
if (Number.isNaN(date.getTime())) {
throw new CommandExecutionError(`Gmail ${label} had an invalid timestamp`);
}
return date.toISOString();
}
function decodeEntities(value) {
return String(value || '')
.replace(/ /gi, ' ')
.replace(/&/gi, '&')
.replace(/</gi, '<')
.replace(/>/gi, '>')
.replace(/"/gi, '"')
.replace(/'|'/gi, "'")View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the capture payload (entry.responsePreview) to see what timestamp value was actually received.
- Update the scraper/bridge if Gmail's DOM changed and the wrong element is being captured.
- Ensure timestamps are supplied as epoch seconds or milliseconds, not preformatted date strings.
- Retry the fetch; a truncated or partial capture may be the cause.
Example fix
// before
{ date: '2024-06-01 12:00' } // string, not epoch
// after
{ date: 1717243200 } // epoch seconds Defensive patterns
Strategy: type-guard
Validate before calling
const ts = Number(value);
if (!Number.isFinite(ts) || ts <= 0) {
throw new Error(`expected epoch seconds/millis, got ${JSON.stringify(value)}`);
} Type guard
function isEpochTimestamp(v) {
const n = Number(v);
return Number.isFinite(n) && n > 0;
} Try / catch
try {
const iso = gmailDate(value, 'search');
} catch (e) {
if (/invalid timestamp/.test(e.message)) {
console.warn('Skipping row with bad timestamp:', value);
return null; // skip instead of failing the batch
}
throw e;
} Prevention
- Ensure the scraper captures the epoch field, not a formatted date string.
- Log raw payloads when a row fails so bad values are visible.
- Test against Gmail DOM changes that can alter which node is scraped.
- Filter or default rows lacking timestamps before processing.
When it happens
Trigger: The browser capture returns a missing/empty date field, a string like 'N/A' or an already-formatted date string ('2024-01-01T...'), or 0/negative epoch values from a malformed batch view or fetch payload.
Common situations: Gmail DOM changes altering what the bridge scrapes; truncated captures dropping the timestamp field; callers feeding preformatted date strings where epoch millis are expected; new/unread items with placeholder timestamps.
Related errors
- archive wayback timestamp must be YYYY[MM[DD[hh[mm[ss]]]]] o
- 无效的时间戳: ${unixSeconds}
- 定时发布时间不能超过 14 天
- flomo memos --since must be a non-negative Unix timestamp in
- Browser session required for gmail attachments
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/94a677057109ab01.
Report an issue: GitHub.