{"record":{"id":"c58cc6e63fac24bd","repo":"github-linguist/linguist","slug":"invalid-type-type","errorCode":null,"errorMessage":"invalid type: #{@type}","messagePattern":"invalid type: #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/linguist/language.rb","lineNumber":270,"sourceCode":"    #\n    # Returns an Array of Languages.\n    def self.colors\n      @colors ||= all.select(&:color).sort_by { |lang| lang.name.downcase }\n    end\n\n    # Internal: Initialize a new Language\n    #\n    # attributes - A hash of attributes\n    def initialize(attributes = {})\n      # @name is required\n      @name = attributes[:name] || raise(ArgumentError, \"missing name\")\n\n      @fs_name = attributes[:fs_name]\n\n      # Set type\n      @type = attributes[:type] ? attributes[:type].to_sym : nil\n      if @type && !get_types.include?(@type)\n        raise ArgumentError, \"invalid type: #{@type}\"\n      end\n\n      @color = attributes[:color]\n\n      # Set aliases\n      @aliases = [default_alias] + (attributes[:aliases] || [])\n\n      @tm_scope = attributes[:tm_scope] || 'none'\n      @ace_mode = attributes[:ace_mode]\n      @codemirror_mode = attributes[:codemirror_mode]\n      @codemirror_mime_type = attributes[:codemirror_mime_type]\n      @wrap = attributes[:wrap] || false\n\n      # Set the language_id\n      @language_id = attributes[:language_id]\n\n      # Set extensions or default to [].\n      @extensions   = attributes[:extensions]   || []","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/github-linguist/linguist/blob/b45dbe9b2825a43285bcd035861be91cc0a7299e/lib/linguist/language.rb#L252-L288","documentation":"Language#initialize converts the `type` attribute to a symbol and validates it against the fixed set returned by get_types: :data, :markup, :programming, :prose (language.rb:305-308). Anything else (or a string that doesn't sym-match one of those four) raises ArgumentError before the language is ever registered. A nil/omitted type passes the check — the error is specifically about a present-but-invalid value. It fires at require time for languages.yml entries and immediately for programmatic Language.new/create calls.","triggerScenarios":"1) A languages.yml entry with `type: script`, `type: mark-up`, or a trailing character (\"programming,\") — YAML hands the string over, to_sym produces an unknown symbol. 2) Passing type: :functional in Language.create. 3) Copying an entry from an older/newer version of the file whose allowed type set differs. The message interpolates the symbol, e.g. \"invalid type: functional\".","commonSituations":"Contributors guessing at type names ('script', 'markup language', 'data-format'); YAML typos and invisible whitespace in the type value; tooling that generates languages.yml with a type vocabulary from a different schema version.","solutions":["Change the type in languages.yml to one of the four valid values: data, markup, programming, or prose.","Check for stray characters — quotes, commas, trailing spaces — around the type value in YAML.","If you genuinely need a new category, that is a library change (extend get_types) — not a per-entry fix; raise it with maintainers instead.","For programmatic use, validate with %i[data markup programming prose].include?(type.to_sym) before construction."],"exampleFix":"# before (lib/linguist/languages.yml)\nTOML:\n  type: data-format\n\n# after\nTOML:\n  type: data","handlingStrategy":"validation","validationCode":"VALID_TYPES = %i[data markup programming prose].freeze\nunless attributes[:type].nil? || VALID_TYPES.include?(attributes[:type].to_sym)\n  raise ArgumentError, \"type must be one of #{VALID_TYPES.join(', ')}\"\nend","typeGuard":"def valid_language_type?(t)\n  %i[data markup programming prose].include?(t.to_sym)\nend","tryCatchPattern":"begin\n  Linguist::Language.create(attributes)\nrescue ArgumentError => e\n  raise if e.message !~ /invalid type/\n  attributes[:type] = :programming # or prompt the author for the right category\nend","preventionTips":["Treat type as a closed enum: data, markup, programming, prose — nothing else.","Beware YAML typos: trailing commas/quotes or whitespace make to_sym produce an unknown symbol.","When copying entries between versions of languages.yml, re-check the type value against the current enum."],"tags":["ruby","yaml","configuration","enum","validation","linguist"],"backgroundTag":"invalid-enum-value","analyzedSha":"b45dbe9b2825a43285bcd035861be91cc0a7299e","analyzedAt":"2026-08-21T15:30:05.145Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}