jackwener/OpenCLI · error · CommandExecutionError
Pixiv bookmark item returned malformed creation date
Error message
Pixiv bookmark item returned malformed creation date
What it means
dateOnly normalizes a Pixiv bookmark item's creation date into a YYYY-MM-DD string. It throws CommandExecutionError when the value is a non-string or does not start with an ISO date (YYYY-MM-DD, optionally followed by 'T'), meaning the API response item was structurally unexpected.
Source
Thrown at clis/pixiv/bookmark-utils.js:23
normalizePixivPositiveInteger,
pixivFetch,
requirePixivId,
requirePixivPayloadObject,
requirePixivString,
} from './utils.js';
export function normalizeBookmarkType(value) {
const type = String(value ?? 'illust').trim();
if (type !== 'illust' && type !== 'novel') {
throw new ArgumentError(`Invalid bookmark type: ${type}. Expected "illust" or "novel".`);
}
return type;
}
export function dateOnly(value) {
if (value == null || value === '') return '';
if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}(?:T|$)/.test(value)) {
throw new CommandExecutionError('Pixiv bookmark item returned malformed creation date');
}
return value.split('T')[0];
}
export function tagsToString(tags) {
if (tags == null) return '';
const values = Array.isArray(tags) ? tags : (Array.isArray(tags?.tags) ? tags.tags : null);
if (!values) {
throw new CommandExecutionError('Pixiv item returned malformed tags payload');
}
return values.map((entry) => {
const value = typeof entry === 'string' ? entry : entry?.tag;
if (typeof value !== 'string' || !value.trim()) {
throw new CommandExecutionError('Pixiv item returned malformed tag');
}
return value.trim();
}).join(', ');
}View on GitHub (pinned to 49907e53dc)
Solutions
- Check the raw API response item and confirm the created date field is an ISO 'YYYY-MM-DD...' string
- Update the library / re-fetch the item in case the response was truncated or stale
- If using a custom endpoint or proxy, verify it does not rewrite date formats; pre-normalize dates to ISO
Example fix
// before item.createdAt = 1735732800000 // after item.createdAt = '2024-01-02T00:00:00+09:00'
Defensive patterns
Strategy: type-guard
Validate before calling
function hasIsoDate(item) { return typeof item?.createdAt === 'string' && /^\d{4}-\d{2}-\d{2}(?:T|$)/.test(item.createdAt); }
if (!bookmarkItems.every(hasIsoDate)) throw new Error('Response contains items with non-ISO createdAt'); Type guard
function isIsoDateString(v) { return typeof v === 'string' && /^\d{4}-\d{2}-\d{2}(?:T|$)/.test(v); } Try / catch
try { const rows = items.map(bookmarkRow); /* ... */ } catch (err) { if (err.message.includes('malformed creation date')) { console.error('Pixiv API returned an item with an invalid date; re-fetching...'); } else throw err; } Prevention
- Validate API response schemas (zod/ajv) before mapping rows
- Prefer official endpoints over proxies that may reformat dates
- Log the raw offending item when this error occurs to spot schema drift early
When it happens
Trigger: Parsing a bookmark list item whose created date field is missing, null-like values that pass the empty check (e.g. whitespace string), numeric timestamps, or API responses in an unexpected date format (e.g. '2024/01/02' or epoch millis).
Common situations: Pixiv API schema changes, partially failed API responses, proxy/mirror endpoints returning reformatted dates, items fetched from unofficial or cached endpoints.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Pixiv item returned malformed tags payload
- Pixiv item returned malformed tag
- Pixiv bookmark item returned malformed ${label}
- ${label} returned a missing image URL
- ${label} returned a malformed image URL
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3edef098ba95a313.
Report an issue: GitHub.