{"record":{"id":"3e3fc6f62aee7131","repo":"dotnet/aspnetcore","slug":"found-malformed-component-comment-at-candidatest","errorCode":null,"errorMessage":"Found malformed component comment at ${candidateStart.textContent}","messagePattern":"Found malformed component comment at (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Services/ComponentDescriptorDiscovery.ts","lineNumber":161,"sourceCode":"        // Regardless of whether this comment matches the type we're looking for, we still need to move the iterator\n        // on to its end position since we don't want to recurse into unrelated prerendered components, nor do we want to get confused\n        // by the end marker.\n        const candidateEnd = getComponentEndComment(componentComment, candidateStart as Comment, commentNodeIterator);\n\n        if (type !== componentComment.type) {\n          return undefined;\n        }\n\n        switch (componentComment.type) {\n          case 'webassembly':\n            return createWebAssemblyComponentComment(componentComment, candidateStart as Comment, candidateEnd);\n          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) {","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Web.JS/src/Services/ComponentDescriptorDiscovery.ts#L143-L179","documentation":"Thrown during component-marker discovery when parsing a Blazor component comment (server/webassembly/auto) raises any exception inside the try block. The catch wraps the underlying error with the comment's textContent for diagnostics. This is a generic 'the prerendered component marker HTML is malformed' signal; the original parse/validation error is masked by this wrapper.","triggerScenarios":"The HTML contains a <!--Blazor:...--> comment whose JSON payload is invalid or missing required fields; a custom HTML pipeline (e.g. an aggressive minifier) rewrote or stripped part of the marker; partial HTML streaming cut a comment in half.","commonSituations":"Output caching/compression that mangles comment payloads; a CDN or proxy that strips HTML comments; hand-edited _Host that broke the marker; version mismatch between prerendering server and client runtime producing different marker schemas.","solutions":["Inspect the raw HTML served to the browser and confirm the <!--Blazor:{...}--> comments are intact and well-formed JSON.","Disable HTML comment stripping in any minifier, CDN, or output cache.","Align the server (prerendering) and client Blazor package versions.","Reproduce by viewing page source and locate the comment whose content is shown in the message, then fix its payload.","If a custom serializer is involved, ensure it emits the exact marker schema."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate served HTML before Blazor reads markers.\nfunction assertCommentsIntact(html: string) {\n  const open = (html.match(/<!--Blazor:/g) || []).length;\n  const close = (html.match(/-->/g) || []).length;\n  if (open === 0) throw new Error('No Blazor component comments found in prerendered HTML.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Disable HTML comment stripping in minifiers/CDNs.","Keep server and client Blazor versions aligned.","Crawl served HTML in CI to confirm markers are intact.","Avoid hand-editing prerendered component comments."],"tags":["blazor","prerendering","markers","html","ssr"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}