jackwener/OpenCLI · error · CommandExecutionError
Bilibili creator comparison returned non-integer metric ${de
Error message
Bilibili creator comparison returned non-integer metric ${definition.key} What it means
Count- and seconds-unit metrics must be safe integers; the value passed Number.isFinite/non-negative validation but is fractional (e.g. 3.5 plays) or exceeds Number.MAX_SAFE_INTEGER. The library rejects it because such values indicate scaling or type drift in the undocumented API rather than real counters.
Source
Thrown at clis/bilibili/creator-stats.js:131
}
return target;
}
function metricValue(target, definition) {
const source = definition.source === 'target' ? target : target.stat;
if (!Object.prototype.hasOwnProperty.call(source, definition.key)) {
throw new CommandExecutionError(`Bilibili creator comparison omitted metric ${definition.key}`);
}
const raw = source[definition.key];
if (raw === null) return null;
if (typeof raw !== 'number' || !Number.isFinite(raw) || raw < 0) {
throw new CommandExecutionError(`Bilibili creator comparison returned malformed metric ${definition.key}`);
}
if (definition.unit === 'percent' && raw > 10_000) {
throw new CommandExecutionError(`Bilibili creator comparison returned out-of-range percentage ${definition.key}`);
}
if ((definition.unit === 'count' || definition.unit === 'seconds') && !Number.isSafeInteger(raw)) {
throw new CommandExecutionError(`Bilibili creator comparison returned non-integer metric ${definition.key}`);
}
return definition.divisor ? raw / definition.divisor : raw;
}
cli({
site: 'bilibili',
name: 'creator-stats',
description: '读取当前账号最近稿件的核心创作指标(需登录创作中心)',
access: 'read',
example: 'opencli bilibili creator-stats <bvid-or-video-url> -f json',
domain: 'member.bilibili.com',
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: `${MEMBER_ORIGIN}/platform/home`,
args: [
{
name: 'bvid',
type: 'string',View on GitHub (pinned to 49907e53dc)
Solutions
- Retry the command to rule out a transient bad payload.
- Check the raw value's magnitude: if duration looks like milliseconds, the CLI needs a unit conversion.
- Update the CLI to round or rescale if Bilibili legitimately changed the representation.
- Use an older manuscript / different video to confirm whether it is data-specific.
Example fix
// caller-side tolerant rounding const raw = target.stat?.[def.key]; const value = Number.isFinite(raw) && raw >= 0 && !Number.isInteger(raw) ? Math.round(raw) : raw;
Defensive patterns
Strategy: validation
Validate before calling
const raw = row?.stat?.[def.key];
if (typeof raw === 'number' && Number.isFinite(raw) && raw >= 0 && (def.unit === 'count' || def.unit === 'seconds') && !Number.isSafeInteger(raw)) {
// fractional or overflowed counter: round or reject
} Type guard
function isSafeNonNegativeInt(v) {
return typeof v === 'number' && Number.isSafeInteger(v) && v >= 0;
} Try / catch
try {
const rows = await creatorStats(bvid);
} catch (e) {
if (/non-integer metric/.test(e.message)) {
// fall back to Math.round of raw value or null
} else throw e;
} Prevention
- Round fractional counters defensively before display
- Check whether duration fields changed unit (ms vs s) after API updates
- Retry once to rule out transient bad payloads
- Keep CLI validators in sync with current API responses
When it happens
Trigger: A count metric (play, like, comment, dm, fav, coin, share, total_new_attention_cnt) or the duration field is a non-integer finite number, e.g. an averaged float from a new API version, or a microsecond/millisecond duration causing non-integral seconds.
Common situations: Bilibili switches duration from seconds to milliseconds-fractional values; A/B rollouts return floating-point counters; large counts near MAX_SAFE_INTEGER from data aggregation bugs.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Bilibili creator comparison returned malformed stat data for
- Bilibili creator comparison returned malformed metric ${defi
- ${label} returned a malformed payload
- Bilibili ${label} API returned malformed top_replies
- Bilibili comments reply ${index + 1} was malformed
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d4741e234368e413.
Report an issue: GitHub.