{"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":null,"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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Services/ComponentDescriptorDiscovery.ts#L155-L191","documentation":"Thrown by parseCommentPayload (ComponentDescriptorDiscovery.ts:173) when a Blazor component marker's JSON has a 'type' field that is not one of 'server', 'webassembly', or 'auto'. The type discriminator tells discovery which renderer should own the component; an unknown value means the marker was produced by a version of the framework the running blazor.*.js does not understand.","triggerScenarios":"A marker comment whose JSON payload has type:<anything-other-than-server|webassembly|auto>; typically a newer/older marker schema served against a mismatched blazor.*.js bundle; hand-edited or cached HTML with a stale marker.","commonSituations":"Version mismatch between the .NET runtime generating markers and the JS bundle interpreting them (e.g. upgraded NuGet package but stale cached blazor.web.js); serving cached prerendered HTML from a CDN after a framework upgrade; A/B testing or edge worker rewriting JSON inside comments.","solutions":["Align the .NET server package version and the blazor.*.js bundle version (check blazor.boot.json hash references).","Bust the CDN/browser cache of blazor.web.js and prerendered HTML after upgrades.","If you customize component marker rendering, ensure type stays within the allowed set.","Reproduce locally with matched versions to confirm the marker is well-formed."],"exampleFix":"// before: cached blazor.web.js v8 reading a v9 'type':'web' marker\n\n// after: clear cached assets and serve matching versions\n// <script src=\"_framework/blazor.web.js\"></script> matches the installed package","handlingStrategy":"validation","validationCode":"const ALLOWED_TYPES = new Set(['server','webassembly','auto']);\nfunction isValidMarkerType(payload: unknown): payload is { type: string } {\n  return typeof payload === 'object' && payload !== null\n    && ALLOWED_TYPES.has((payload as any).type);\n}","typeGuard":"function isKnownComponentType(type: string): type is 'server'|'webassembly'|'auto' {\n  return type === 'server' || type === 'webassembly' || type === 'auto';\n}","tryCatchPattern":null,"preventionTips":["Pin server and blazor.*.js to the same release.","Cache-bust blazor.web.js and prerendered HTML after upgrades.","Do not hand-build component markers."],"tags":["blazor","ssr","markers","version-mismatch","schema","cache"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}