{"record":{"id":"75853a5b1e781e4c","repo":"pbakaus/impeccable","slug":"svelte-component-source-file-not-found-sourcefi","errorCode":null,"errorMessage":"Svelte-component source file not found: ${sourceFile}","messagePattern":"Svelte-component source file not found: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugin/skills/impeccable/scripts/live/svelte-component.mjs","lineNumber":452,"sourceCode":"export function readManifest(manifestPath) {\n  const data = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));\n  return {\n    ...data,\n    manifestPath,\n  };\n}\n\nexport function resolveSourceFile(sourceFile, cwd = process.cwd()) {\n  if (!sourceFile || path.isAbsolute(sourceFile)) {\n    throw new Error('Invalid svelte-component source file');\n  }\n  const full = path.resolve(cwd, sourceFile);\n  const rel = path.relative(cwd, full);\n  if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) {\n    throw new Error('Svelte-component source file escapes project root');\n  }\n  if (!fs.existsSync(full)) {\n    throw new Error('Svelte-component source file not found: ' + sourceFile);\n  }\n  return full;\n}\n\nfunction appendCssToSvelteStyle(lines, cssLines) {\n  const closeIdx = findLastStyleCloseLine(lines);\n  const prepared = ['', ...cssLines.map((line) => (line.trim() === '' ? '' : '  ' + line.trimStart()))];\n  if (closeIdx === -1) {\n    return [...lines, '', '<style>', ...prepared.slice(1), '</style>'];\n  }\n  return [\n    ...lines.slice(0, closeIdx),\n    ...prepared,\n    ...lines.slice(closeIdx),\n  ];\n}\n\nfunction findLastStyleCloseLine(lines) {","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/plugin/skills/impeccable/scripts/live/svelte-component.mjs#L434-L470","documentation":"Thrown by resolveSourceFile when the path passes the absolute and escape guards but the resolved file does not exist on disk. This is the final existence check before the function returns the absolute path to the caller.","triggerScenarios":"Calling resolveSourceFile('src/lib/Missing.svelte', cwd) where the file has not been created yet, was deleted, or is misspelled.","commonSituations":"Component not yet generated, a typo in the manifest sourceFile field, or a stale manifest pointing at a renamed/removed file.","solutions":["Verify the file path spelling and that it exists relative to cwd.","If the component is generated by the adapter, ensure the generation step ran before resolveSourceFile is called.","Update the manifest's sourceFile field to the current file location."],"exampleFix":"// before: file does not exist yet\nresolveSourceFile('src/lib/Comp.svelte', cwd);\n\n// after: ensure the file exists first\nif (!fs.existsSync(path.join(cwd, 'src/lib/Comp.svelte'))) {\n  throw new Error('generate the component before resolving');\n}\nresolveSourceFile('src/lib/Comp.svelte', cwd);","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\nfunction sourceFileExists(sourceFile, cwd) {\n  return fs.existsSync(path.resolve(cwd, sourceFile));\n}","typeGuard":"function isExistingSource(sourceFile, cwd) {\n  return typeof sourceFile === 'string' && !path.isAbsolute(sourceFile) && fs.existsSync(path.resolve(cwd, sourceFile));\n}","tryCatchPattern":"try {\n  resolveSourceFile(sourceFile, cwd);\n} catch (err) {\n  if (err.message.startsWith('Svelte-component source file not found')) {\n    await generateComponent(sourceFile);\n    resolveSourceFile(sourceFile, cwd);\n  } else throw err;\n}","preventionTips":["Generate components before resolving their source path.","Keep manifest sourceFile fields in sync after renames via a repo-wide grep.","Add an existence assertion in manifest-loading code to fail earlier."],"tags":["filesystem","path","svelte","validation"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}