{"record":{"id":"1c921d796485f94f","repo":"agalwood/Motrix","slug":"accuracy-is-not-legal","errorCode":null,"errorMessage":"accuracy is not legal","messagePattern":"accuracy is not legal","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"src/core/inspector-activity/validators.ts","lineNumber":174,"sourceCode":"  }\n}\n\nexport function validateHistoryEventInput(input: TaskHistoryEventInput): void {\n  assertTaskId(input.taskId)\n  assertPositiveSafeInteger(input.eventOrdinal, 'eventOrdinal')\n  assertBoundedText(input.eventKey, 'eventKey', MAX_EVENT_KEY_LENGTH)\n  assertBoundedText(\n    input.runtimeGeneration,\n    'runtimeGeneration',\n    MAX_EVENT_KEY_LENGTH\n  )\n  assertPositiveSafeInteger(input.occurredAt, 'occurredAt')\n  assertNonNegativeSafeInteger(input.occurredMonotonicMs, 'occurredMonotonicMs')\n  if (!EVENT_KIND_VALUES.has(input.kind)) {\n    throw new RangeError('kind is not a legal history event kind')\n  }\n  if (!ACCURACY_VALUES.has(input.accuracy)) {\n    throw new RangeError('accuracy is not legal')\n  }\n  if (!DELIVERY_VALUES.has(input.delivery)) {\n    throw new RangeError('delivery is not legal')\n  }\n  assertStatus(input.fromStatus, 'fromStatus')\n  assertStatus(input.toStatus, 'toStatus')\n  if (input.toStatus === null) {\n    throw new RangeError('toStatus is required')\n  }\n  assertBoundedText(input.errorCode, 'errorCode', MAX_ERROR_CODE_LENGTH)\n  assertBoundedText(\n    input.errorMessage,\n    'errorMessage',\n    MAX_ERROR_MESSAGE_LENGTH\n  )\n  assertBoundedText(\n    input.errorDetailKey,\n    'errorDetailKey',","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/agalwood/Motrix/blob/1a708ee57746c434e2c67a44bbf0906a976afea4/src/core/inspector-activity/validators.ts#L156-L192","documentation":"`input.accuracy` must be one of `TaskHistoryAccuracy.Exact` (`'exact'`) or `TaskHistoryAccuracy.Recovered` (`'recovered'`). It distinguishes events recorded live from those reconstructed after a coverage gap. Throws this `RangeError` on any other value.","triggerScenarios":"An event submitted with `accuracy` set to `undefined`, an empty string, or a foreign value (`'approximate'`). Common when a producer omits the field and a defaulting layer fills it incorrectly, or when serializing from a schema that pre-dates the accuracy flag.","commonSituations":"New producers forgetting to set accuracy; replaying events from a schema predating the accuracy flag; tests that leave it unset.","solutions":["Default to `TaskHistoryAccuracy.Exact` at the producer for live events, `Recovered` for reconstructed ones.","Reference the enum, not the string.","If unsure, treat the event as recovered and let the consumer downgrade trust."],"exampleFix":"// before\ninput.accuracy = recordedLive ? 'live' : 'guess'\n// after\ninput.accuracy = recordedLive ? TaskHistoryAccuracy.Exact : TaskHistoryAccuracy.Recovered","handlingStrategy":"type-guard","validationCode":"import { TaskHistoryAccuracy } from '@shared/types/task-inspector-activity'\nfunction coerceAccuracy(v: unknown): TaskHistoryAccuracy {\n  return v === TaskHistoryAccuracy.Recovered\n    ? TaskHistoryAccuracy.Recovered\n    : TaskHistoryAccuracy.Exact\n}","typeGuard":"import { TaskHistoryAccuracy } from '@shared/types/task-inspector-activity'\nconst ACC = new Set(Object.values(TaskHistoryAccuracy))\nfunction isAccuracy(v: unknown): v is TaskHistoryAccuracy {\n  return typeof v === 'string' && ACC.has(v)\n}","tryCatchPattern":null,"preventionTips":["Always set `accuracy` when building an event — never let it default through `undefined`.","Prefer the enum members over string literals."],"tags":["validation","range-error","enums"],"backgroundTag":null,"analyzedSha":"1a708ee57746c434e2c67a44bbf0906a976afea4","analyzedAt":"2026-08-12T16:18:09.346Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}