{"record":{"id":"901eb3ac969cdbe7","repo":"stablyai/orca","slug":"orca-doc-link-bench-iterations-must-be-a-positive","errorCode":null,"errorMessage":"ORCA_DOC_LINK_BENCH_ITERATIONS must be a positive integer, got ${ITERATIONS}","messagePattern":"ORCA_DOC_LINK_BENCH_ITERATIONS must be a positive integer, got (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/rich-markdown-doc-link-scan-benchmark.mjs","lineNumber":20,"sourceCode":"// Measures the complete ProseMirror doc traversal used by the two doc-link plugins.\nimport { execFileSync } from 'node:child_process'\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { performance } from 'node:perf_hooks'\nimport { fileURLToPath } from 'node:url'\nimport { Schema } from '@tiptap/pm/model'\nimport {\n  canHoldDocLink,\n  DOC_LINK_PATTERN,\n  isDocLinkLiteralCodeTextNode\n} from '../../src/renderer/src/components/editor/rich-markdown-doc-link-scan.ts'\n\nconst REPO_ROOT = fileURLToPath(new URL('../..', import.meta.url))\nconst ITERATIONS = Number(process.env.ORCA_DOC_LINK_BENCH_ITERATIONS ?? '41')\nconst WARMUP_ITERATIONS = Math.min(9, ITERATIONS)\n\nif (!Number.isSafeInteger(ITERATIONS) || ITERATIONS <= 0) {\n  throw new Error(`ORCA_DOC_LINK_BENCH_ITERATIONS must be a positive integer, got ${ITERATIONS}`)\n}\n\nconst schema = new Schema({\n  nodes: {\n    doc: { content: 'paragraph+' },\n    paragraph: { content: 'text*' },\n    text: { group: 'inline' }\n  }\n})\n\nfunction walkUngated(doc) {\n  let matches = 0\n  let visited = 0\n  doc.descendants((node, _pos, parent) => {\n    visited += 1\n    if (node.type.name !== 'text' || !node.text || isDocLinkLiteralCodeTextNode(node, parent)) {\n      return\n    }","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/rich-markdown-doc-link-scan-benchmark.mjs#L2-L38","documentation":"Thrown by the doc-link scan benchmark when ORCA_DOC_LINK_BENCH_ITERATIONS is not a safe positive integer. The value controls measured rounds of ProseMirror doc traversal across repo markdown files; warmup is clamped to min(9, ITERATIONS).","triggerScenarios":"Setting ORCA_DOC_LINK_BENCH_ITERATIONS to 0, a negative number, a decimal, Infinity, or a non-numeric string. Number.isSafeInteger rejects all of these. The default is 41.","commonSituations":"A developer sets iterations to 0 for a dry run, or passes a large number exceeding Number.MAX_SAFE_INTEGER (rare).","solutions":["Omit the env var to use the default of 41 iterations.","Set it to a positive integer, e.g. ORCA_DOC_LINK_BENCH_ITERATIONS=100."],"exampleFix":"// before\nORCA_DOC_LINK_BENCH_ITERATIONS=0 node config/scripts/rich-markdown-doc-link-scan-benchmark.mjs\n// after\nORCA_DOC_LINK_BENCH_ITERATIONS=100 node config/scripts/rich-markdown-doc-link-scan-benchmark.mjs","handlingStrategy":"validation","validationCode":"const ITERATIONS = Number(process.env.ORCA_DOC_LINK_BENCH_ITERATIONS ?? '41')\nif (!Number.isSafeInteger(ITERATIONS) || ITERATIONS <= 0) {\n  throw new Error(`ORCA_DOC_LINK_BENCH_ITERATIONS must be a positive integer, got ${ITERATIONS}`)\n}","typeGuard":"function isSafePositiveInt(value) {\n  return Number.isSafeInteger(value) && value > 0\n}","tryCatchPattern":null,"preventionTips":["Use Number.isSafeInteger rather than Number.isInteger to reject Infinity and large floats.","Default to a sensible round number (41 here) so most runs need no env var."],"tags":["benchmark","env-var","validation","prosemirror","doc-link"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}