{"record":{"id":"a310b1d62ec390c4","repo":"ViewComponent/view_component","slug":"warning-the-self-class-component-was-provided","errorCode":null,"errorMessage":"WARNING: The #{self.class} component was provided an HTML-unsafe preamble. The preamble will be automatically escaped, but you may want to investigate.","messagePattern":"WARNING: The #(.+?) component was provided an HTML-unsafe preamble\\. The preamble will be automatically escaped, but you may want to investigate\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/view_component/base.rb","lineNumber":450,"sourceCode":"    def __vc_content_set_by_with_content_defined?\n      defined?(@__vc_content_set_by_with_content)\n    end\n\n    def __vc_maybe_escape_html(text)\n      return text if @current_template && !@current_template.html?\n      return text if text.blank?\n\n      if text.html_safe?\n        text\n      else\n        yield\n        html_escape(text)\n      end\n    end\n\n    def __vc_safe_output_preamble\n      __vc_maybe_escape_html(output_preamble) do\n        Kernel.warn(\"WARNING: The #{self.class} component was provided an HTML-unsafe preamble. The preamble will be automatically escaped, but you may want to investigate.\")\n      end\n    end\n\n    def __vc_safe_output_postamble\n      __vc_maybe_escape_html(output_postamble) do\n        Kernel.warn(\"WARNING: The #{self.class} component was provided an HTML-unsafe postamble. The postamble will be automatically escaped, but you may want to investigate.\")\n      end\n    end\n\n    def __vc_safe_around_render_output(output)\n      __vc_maybe_escape_html(output) do\n        Kernel.warn(\"WARNING: The #{self.class} component's around_render returned an HTML-unsafe string. The output will be automatically escaped, but you may want to investigate.\")\n      end\n    end\n\n    # Resets every render-scoped instance variable derived from the calling view\n    # context so a reused instance cannot leak controller/helper/request/format\n    # state from a previous render. Slot state (`@__vc_set_slots`,","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/ViewComponent/view_component/blob/9f22c36fa7d7b44098a8ed97472e3b4674ae420f/lib/view_component/base.rb#L432-L468","documentation":"Error \"WARNING: The #{self.class} component was provided an HTML-unsafe preamble. The preamble will be automatically escaped, but you may want to investigate.\" thrown in ViewComponent/view_component.","triggerScenarios":"Thrown at lib/view_component/base.rb:450 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Mark the preamble string HTML-safe with `.html_safe` only after verifying it contains no untrusted/user-supplied data.","Otherwise sanitize the preamble (e.g. with Rails' `sanitize` helper) or escape interpolations with `ERB::Util.html_escape` before returning it."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9f22c36fa7d7b44098a8ed97472e3b4674ae420f","analyzedAt":"2026-08-23T10:20:47.008Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}