{"record":{"id":"0ac16280405f27e2","repo":"ViewComponent/view_component","slug":"warning-template-format-for-path-is-missing-d","errorCode":null,"errorMessage":"WARNING: Template format for #{path} is missing, defaulting to :html.","messagePattern":"WARNING: Template format for #(.+?) is missing, defaulting to :html\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/view_component/template.rb","lineNumber":27,"sourceCode":"\n    attr_reader :details, :path\n\n    delegate :virtual_path, to: :@component\n    delegate :format, :variant, to: :@details\n\n    def initialize(component:, details:, lineno: nil, path: nil)\n      @component = component\n      @details = details\n      @lineno = lineno\n      @path = path\n    end\n\n    class File < Template\n      def initialize(component:, details:, path:)\n        # If the template file has no format (e.g. .erb instead of .html.erb),\n        # assume the default format (html).\n        if details.format.nil?\n          Kernel.warn(\"WARNING: Template format for #{path} is missing, defaulting to :html.\")\n          details = ActionView::TemplateDetails.new(details.locale, details.handler, DEFAULT_FORMAT, details.variant)\n        end\n\n        super\n      end\n\n      def type\n        :file\n      end\n\n      # Load file each time we look up #source in case the file has been modified\n      def source\n        ::File.read(@path)\n      end\n\n      private\n\n      # Rails 8.1 added a newline to compiled ERB output (rails/rails#53731).","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/ViewComponent/view_component/blob/9f22c36fa7d7b44098a8ed97472e3b4674ae420f/lib/view_component/template.rb#L9-L45","documentation":"Error \"WARNING: Template format for #{path} is missing, defaulting to :html.\" thrown in ViewComponent/view_component.","triggerScenarios":"Thrown at lib/view_component/template.rb:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add an explicit format to the template file name, e.g. rename my_component.erb to my_component.html.erb.","If another format is intended, name the template accordingly, e.g. my_component.json.jbuilder."],"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"}