{"record":{"id":"8460157256ca2abe","repo":"evanw/esbuild","slug":"failed-to-find-id-in-input","errorCode":null,"errorMessage":"Failed to find \"${id}\" in input","messagePattern":"Failed to find \"(.+?)\" in input","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/verify-source-map.js","lineNumber":848,"sourceCode":"    // Check the mapping of various key locations back to the original source\n    const checkMap = (out, map) => {\n      for (const id in toSearch) {\n        const outIndex = out.indexOf(`\"${id}\"`)\n        if (outIndex < 0) throw new Error(`Failed to find \"${id}\" in output`)\n        const outLines = out.slice(0, outIndex).split('\\n')\n        const outLine = outLines.length\n        const outLastLine = outLines[outLines.length - 1]\n        let outColumn = outLastLine.length\n        const { source, line, column } = map.originalPositionFor({ line: outLine, column: outColumn })\n\n        const inSource = isStdin ? '<stdin>' : toSearch[id]\n        recordCheck(decodeURI(source) === inSource, `expected source: ${inSource}, observed source: ${source}`)\n\n        const inCode = map.sourceContentFor(source)\n        if (inCode === null) throw new Error(`Got null for source content for \"${source}\"`)\n        let inIndex = inCode.indexOf(`\"${id}\"`)\n        if (inIndex < 0) inIndex = inCode.indexOf(`'${id}'`)\n        if (inIndex < 0) throw new Error(`Failed to find \"${id}\" in input`)\n        const inLines = inCode.slice(0, inIndex).split('\\n')\n        const inLine = inLines.length\n        const inLastLine = inLines[inLines.length - 1]\n        let inColumn = inLastLine.length\n\n        const expected = JSON.stringify({ source, line: inLine, column: inColumn })\n        const observed = JSON.stringify({ source, line, column })\n        recordCheck(expected === observed, `expected original position: ${expected}, observed original position: ${observed}`)\n\n        // Also check the reverse mapping\n        const positions = map.allGeneratedPositionsFor({ source, line: inLine, column: inColumn })\n        recordCheck(positions.length > 0, `expected generated positions: 1, observed generated positions: ${positions.length}`)\n        let found = false\n        for (const { line, column } of positions) {\n          if (line === outLine && column === outColumn) {\n            found = true\n            break\n          }","sourceCodeStart":830,"sourceCodeEnd":866,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/scripts/verify-source-map.js#L830-L866","documentation":"Thrown at scripts/verify-source-map.js:848. Having obtained the original source content via sourceContentFor, the harness searches that text for the quoted token `\"id\"` (falling back to single-quoted `'id'`). A negative indexOf means the identifier the harness expected to map is not actually present in the original source file, so the original line/column cannot be computed.","triggerScenarios":"A toSearch entry references an identifier that does not exist in the corresponding input source file — a typo in the identifier, a stale toSearch entry after the input was edited, or a mismatch where toSearch maps an id to the wrong source path.","commonSituations":"A contributor edits an input fixture and removes/renames an identifier but leaves the toSearch table pointing at the old name, or assigns the identifier to the wrong source file.","solutions":["Open the input source named by toSearch[id] and confirm the identifier exists there in quoted form.","Correct the toSearch entry: fix the identifier spelling, or remap it to the source file that actually contains it.","If the identifier legitimately uses different quoting, ensure the single-quote fallback covers it."],"exampleFix":"// before (id not present in input 'a.js')\nconst toSearch = { missing: 'a.js' }\n\n// after (point at the file that actually contains the id)\nconst toSearch = { missing: 'b.js' }","handlingStrategy":"validation","validationCode":"function idExistsInSource(inCode, id) {\n  return inCode.indexOf(`\"${id}\"`) >= 0 || inCode.indexOf(`'${id}'`) >= 0;\n}","typeGuard":null,"tryCatchPattern":"try { checkMap(outCode, outMap); }\ncatch (e) {\n  if (/Failed to find .* in input/.test(e.message)) console.error('toSearch id is not present in its mapped source file:', e.message);\n  throw e;\n}","preventionTips":["Keep the toSearch table in sync with the input fixtures — update both when renaming an identifier.","Map each id to the source file that actually contains it.","Verify the id appears quoted in the input before adding it to toSearch."],"tags":["test-harness","source-map","verification","validation","input"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}