{"record":{"id":"0f8caf86d32d8fdd","repo":"amruthpillai/reactive-resume","slug":"applied-semantic-stylesheet-cannot-be-projected","errorCode":null,"errorMessage":"Applied semantic stylesheet cannot be projected","messagePattern":"Applied semantic stylesheet cannot be projected","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/pdf/src/semantic/public-projection.ts","lineNumber":263,"sourceCode":"\tdata: ResumeData,\n\tnodes: PublicStyleProjection[\"nodes\"],\n\tprojection: ProjectionFingerprints,\n): Promise<string> =>\n\tcomputeRenderDataHash({\n\t\tdomainVersion: 1,\n\t\tdata: projectPublicRenderData(data),\n\t\tresolvedNodes: nodes,\n\t\tprojectionFingerprints: projection,\n\t});\n\nexport async function createPublicStyleProjection(input: { data: ResumeData }): Promise<PublicStyleProjection> {\n\tconst runtime = resolveResumeRuntime({\n\t\tdata: input.data,\n\t\ttemplate: input.data.metadata.template,\n\t\tmode: resolveStylesheetMode(input.data),\n\t});\n\tif (runtime.diagnostics.some(({ severity }) => severity === \"error\")) {\n\t\tthrow new Error(\"Applied semantic stylesheet cannot be projected\");\n\t}\n\n\tconst structure = projectNodeStructure(runtime.sourceTree, runtime.renderTree);\n\tconst nodes = Object.freeze(\n\t\tObject.fromEntries(\n\t\t\tObject.entries(runtime.presentation).map(([nodeKey, presentation]) => [\n\t\t\t\tnodeKey,\n\t\t\t\ttoPublicNode(presentation, structure[nodeKey] ?? {}),\n\t\t\t]),\n\t\t),\n\t);\n\tconst projection = await projectionFingerprints(input.data);\n\treturn Object.freeze({\n\t\t...projection,\n\t\trenderDataHash: await hashProjection(input.data, nodes, projection),\n\t\tnodes,\n\t});\n}","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/amruthpillai/reactive-resume/blob/3a5b12e2a40374a9571988701fcb75c5a1831c42/packages/pdf/src/semantic/public-projection.ts#L245-L281","documentation":"createPublicStyleProjection resolves the resume runtime with the applied semantic stylesheet and inspects runtime.diagnostics; if any diagnostic has severity 'error' it throws, refusing to project a stylesheet that didn't compile cleanly. The projection is the public, shareable view of the resume's presentation, so an errored stylesheet cannot be exposed.","triggerScenarios":"A semantic stylesheet that references unknown nodes/roles, has invalid selector syntax, or otherwise fails compilation; running projection right after applying a stylesheet that produced diagnostics the caller ignored.","commonSituations":"User-saved or imported stylesheet with a syntax error or unknown role; a version mismatch where the stylesheet targets node keys removed in the current schema; AI-generated stylesheet that didn't validate.","solutions":["Resolve the resume runtime / compile the stylesheet first and surface diagnostics to the user before persisting or projecting.","Fix every 'error'-severity diagnostic in the stylesheet (unknown roles, invalid selectors, missing node refs).","Gate the 'publish/share' action on diagnostics.filter(d => d.severity === 'error').length === 0.","If migrating, regenerate the stylesheet from the current schema's semantic registry."],"exampleFix":"// before: project immediately after applying\nawait applyStylesheet(resumeId, source);\nconst projection = await createPublicStyleProjection({ data });\n// after: check diagnostics first\nconst runtime = resolveResumeRuntime({ data, template, mode });\nconst errors = runtime.diagnostics.filter(d => d.severity === 'error');\nif (errors.length) return showErrors(errors);\nconst projection = await createPublicStyleProjection({ data });","handlingStrategy":"validation","validationCode":"const runtime = resolveResumeRuntime({ data, template: data.metadata.template, mode });\nif (runtime.diagnostics.some(d => d.severity === 'error')) {\n  throw new Error('Cannot project: stylesheet has errors.');\n}","typeGuard":"function hasErrorDiagnostics(runtime: { diagnostics: { severity: string }[] }): boolean {\n  return runtime.diagnostics.some(d => d.severity === 'error');\n}","tryCatchPattern":"try { await createPublicStyleProjection({ data }); }\ncatch (e) { if (/cannot be projected/i.test(String((e as Error).message))) { /* surface compile diagnostics */ } throw e; }","preventionTips":["Surface compiler diagnostics before persisting/applying a stylesheet.","Gate publish/share actions on zero error diagnostics.","Regenerate stylesheets after schema migrations."],"tags":["stylesheet","semantic","pdf","projection","diagnostics"],"backgroundTag":null,"analyzedSha":"3a5b12e2a40374a9571988701fcb75c5a1831c42","analyzedAt":"2026-08-12T22:31:22.666Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}