{"record":{"id":"1af325a37fc433c1","repo":"trpc/trpc","slug":"not-working-for-file","errorCode":null,"errorMessage":"Not working for ${file}","messagePattern":"Not working for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"www/src/components/sponsors/script.push.ts","lineNumber":157,"sourceCode":"\n  markdown.push(table);\n}\n\nconst markdownStr = markdown.join('\\n\\n');\nconst rootPath = __dirname + '/../../../..';\n\nconst files = [\n  `${rootPath}/README.md`,\n  `${rootPath}/www/unversioned/_sponsors.mdx`,\n];\n\nfor (const file of files) {\n  const str = fs.readFileSync(file).toString();\n  const start = '<!-- SPONSORS:LIST:START -->';\n  const end = '<!-- SPONSORS:LIST:END -->';\n\n  if (str.indexOf(start) >= str.indexOf(end)) {\n    throw new Error(`Not working for ${file}`);\n  }\n\n  const newContents = str.replace(\n    str.substring(str.indexOf(start) + start.length, str.lastIndexOf(end)),\n    [\n      '',\n      '<!-- prettier-ignore-start -->',\n      '<!-- markdownlint-disable -->',\n      '',\n      markdownStr,\n      '',\n      '<!-- markdownlint-restore -->',\n      '<!-- prettier-ignore-end -->',\n      '\\n',\n    ].join('\\n'),\n  );\n  fs.writeFileSync(file, newContents);\n}","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/trpc/trpc/blob/acff82332de8b4562d3e6975fa8d94ab1a6de5e0/www/src/components/sponsors/script.push.ts#L139-L175","documentation":"script.push.ts writes the generated sponsors markdown into files bounded by <!-- SPONSORS:LIST:START --> and <!-- SPONSORS:LIST:END --> markers. It throws 'Not working for ${file}' when the START marker appears at or after the END marker (indexOf(start) >= indexOf(end)), meaning the markers are missing or out of order, which would make a blind replace corrupt the file.","triggerScenarios":"Reading README.md or www/unversioned/_sponsors.mdx where the SPONSORS:LIST:START/END comment markers have been removed, reordered, or never added. indexOf returns -1 for a missing marker, and -1 >= -1 (or -1 >= realIndex) triggers the guard.","commonSituations":"A previous edit accidentally deleting a marker; markers reformatted by a linter that strips HTML comments; the file being replaced/reset without the marker template; a manual edit putting END before START.","solutions":["Restore both markers in the affected file: <!-- SPONSORS:LIST:START --> ... <!-- SPONSORS:LIST:END --> with START before END.","If a marker was deleted, copy the marker block from git history (git show HEAD:path).","Ensure prettier/markdownlint is not configured to strip HTML comments in those files.","Re-run the push script after fixing the markers."],"exampleFix":"# before (END marker missing or before START)\n<!-- SPONSORS:LIST:END -->\n<!-- SPONSORS:LIST:START -->\n# after\n<!-- SPONSORS:LIST:START -->\n... sponsors ...\n<!-- SPONSORS:LIST:END -->","handlingStrategy":"validation","validationCode":"// Verify markers before running the push script\nconst START = '<!-- SPONSORS:LIST:START -->';\nconst END = '<!-- SPONSORS:LIST:END -->';\nfor (const file of files) {\n  const s = fs.readFileSync(file, 'utf8');\n  if (s.indexOf(START) === -1 || s.indexOf(END) === -1 || s.indexOf(START) >= s.indexOf(END)) {\n    throw new Error(`Markers malformed in ${file}`);\n  }\n}","typeGuard":"function hasValidMarkers(text: string): boolean {\n  const s = text.indexOf('<!-- SPONSORS:LIST:START -->');\n  const e = text.indexOf('<!-- SPONSORS:LIST:END -->');\n  return s !== -1 && e !== -1 && s < e;\n}","tryCatchPattern":null,"preventionTips":["Commit the marker block to the template so it is never lost.","Exclude sponsor files from linters that strip HTML comments.","Add a CI step that verifies markers exist before the push script runs.","Keep markers in a single canonical location."],"tags":["sponsors","file-format","markers","docs"],"backgroundTag":null,"analyzedSha":"acff82332de8b4562d3e6975fa8d94ab1a6de5e0","analyzedAt":"2026-08-12T22:04:41.179Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}