{"record":{"id":"9c8518fc1c5f609a","repo":"dotnet/aspnetcore","slug":"invalid-component-type-type","errorCode":null,"errorMessage":"Invalid component type '${type}'.","messagePattern":"Invalid component type '(.+?)'\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Services/ComponentDescriptorDiscovery.ts","lineNumber":173,"sourceCode":"          case 'server':\n            return createServerComponentComment(componentComment, candidateStart as Comment, candidateEnd);\n          case 'auto':\n            return createAutoComponentComment(componentComment, candidateStart as Comment, candidateEnd);\n        }\n      } catch (error) {\n        throw new Error(`Found malformed component comment at ${candidateStart.textContent}`);\n      }\n    } else {\n      return;\n    }\n  }\n}\n\nfunction parseCommentPayload(json: string): ServerComponentMarker | WebAssemblyComponentMarker | AutoComponentMarker {\n  const payload = JSON.parse(json);\n  const { type } = payload;\n  if (type !== 'server' && type !== 'webassembly' && type !== 'auto') {\n    throw new Error(`Invalid component type '${type}'.`);\n  }\n\n  return payload;\n}\n\nfunction assertNotDirectlyOnDocument(marker: Node) {\n  if (marker.parentNode instanceof Document) {\n    throw new Error('Root components cannot be marked as interactive. The <html> element must be rendered statically so that scripts are not evaluated multiple times.');\n  }\n}\n\nfunction getComponentEndComment(payload: ComponentMarker, start: Comment, iterator: ComponentCommentIterator): Comment | undefined {\n  const { prerenderId } = payload;\n  if (!prerenderId) {\n    return undefined;\n  }\n\n  while (iterator.next() && iterator.currentElement) {","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Web.JS/src/Services/ComponentDescriptorDiscovery.ts#L155-L191","documentation":"Thrown by parseCommentPayload after JSON.parse of a component comment if the resulting object's 'type' field is not one of 'server', 'webassembly', or 'auto'. These three are the only supported component marker types; any other value (or missing type) is rejected before the payload is returned.","triggerScenarios":"A Blazor component comment with type set to an unrecognized string (e.g. 'client', 'razor'); the type field missing so it is undefined; a hand-crafted or corrupted marker.","commonSituations":"Custom tooling that emits component markers with a non-standard type; corruption of the JSON payload; a future/newer Blazor version emitting a type this older runtime doesn't know.","solutions":["Ensure the prerendering layer emits exactly 'server', 'webassembly', or 'auto'.","Update the client-side Blazor runtime to match the server's version so all marker types are recognized.","Remove any custom code that synthesizes Blazor component markers.","Inspect the comment payload in the served HTML and correct the type field."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const VALID = new Set(['server', 'webassembly', 'auto']);\nfunction assertMarkerType(payload: any) {\n  if (!VALID.has(payload?.type)) {\n    throw new Error(`Unsupported marker type '${payload?.type}'.`);\n  }\n}","typeGuard":"function isMarkerType(v: unknown): v is 'server' | 'webassembly' | 'auto' {\n  return v === 'server' || v === 'webassembly' || v === 'auto';\n}","tryCatchPattern":null,"preventionTips":["Only emit official marker types from the prerendering pipeline.","Align server and client runtime versions.","Don't synthesize Blazor component markers in custom code."],"tags":["blazor","prerendering","markers","validation"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}