{"record":{"id":"f8ca16bdc45b4a5f","repo":"ViewComponent/view_component","slug":"warning-the-self-class-component-rendered-html","errorCode":null,"errorMessage":"WARNING: The #{self.class} component rendered HTML-unsafe output. The output will be automatically escaped, but you may want to investigate.","messagePattern":"WARNING: The #(.+?) component rendered HTML-unsafe output\\. The output will be automatically escaped, but you may want to investigate\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/view_component/template.rb","lineNumber":134,"sourceCode":"        super(component: component, details: details)\n\n        @call_method_name = method_name\n        @defined_on_self = defined_on_self\n      end\n\n      def type\n        :inline_call\n      end\n\n      def compile_to_component\n        @component.define_method(safe_method_name, @component.instance_method(@call_method_name))\n      end\n\n      def safe_method_name_call\n        m = safe_method_name\n        proc do\n          __vc_maybe_escape_html(send(m)) do\n            Kernel.warn(\"WARNING: The #{self.class} component rendered HTML-unsafe output. \" \\\n                          \"The output will be automatically escaped, but you may want to investigate.\")\n          end\n        end\n      end\n\n      def defined_on_self?\n        @defined_on_self\n      end\n    end\n\n    def compile_to_component\n      @component.silence_redefinition_of_method(call_method_name)\n\n      # rubocop:disable Style/EvalWithLocation\n      @component.class_eval <<~RUBY, @path, lineno\n        def #{call_method_name}\n          #{compiled_source}\n        end","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/ViewComponent/view_component/blob/9f22c36fa7d7b44098a8ed97472e3b4674ae420f/lib/view_component/template.rb#L116-L152","documentation":"Error \"WARNING: The #{self.class} component rendered HTML-unsafe output. The output will be automatically escaped, but you may want to investigate.\" thrown in ViewComponent/view_component.","triggerScenarios":"Thrown at lib/view_component/template.rb:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return an HTML-safe string from the template/call method: build output via the output buffer, `safe_join`, or `content_tag`, or mark it `.html_safe` only after escaping all untrusted input.","Escape interpolations with `ERB::Util.html_escape`/`h` before concatenating them into the returned string."],"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"}