{"record":{"id":"94eca7e0f4e5bb8a","repo":"instructure/canvas-lms","slug":"options-must-be-a-hash","errorCode":null,"errorMessage":"Options must be a hash","messagePattern":"Options must be a hash","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"app/models/llm_config.rb","lineNumber":67,"sourceCode":"    end\n\n    new_options.each_value do |value|\n      if value.is_a?(String) && (remaining_placeholder = value.match(/<\\w+_PLACEHOLDER>/))\n        raise ArgumentError, \"Options still contain placeholder: #{remaining_placeholder[0]}\"\n      end\n    end\n\n    [new_template, new_options]\n  end\n\n  private\n\n  def validate!\n    raise ArgumentError, \"Name must be a string\" unless @name.is_a?(String)\n    raise ArgumentError, \"Model ID must be a string\" unless @model_id.is_a?(String)\n    raise ArgumentError, \"Rate limit must be either nil, or hash with :limit and :period keys\" unless @rate_limit.nil? || (@rate_limit.is_a?(Hash) && @rate_limit.keys == %i[limit period])\n    raise ArgumentError, \"Template must be a string\" unless @template.is_a?(String)\n    raise ArgumentError, \"Options must be a hash\" unless @options.is_a?(Hash)\n  end\nend\n","sourceCodeStart":49,"sourceCodeEnd":70,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/llm_config.rb#L49-L70","documentation":"LlmConfig#validate! raises ArgumentError when options is not a Hash. options holds per-request LLM parameters (temperature, messages, etc.) and must be a hash that generate_prompt_and_options can deep_dup and substitute into.","triggerScenarios":"LlmConfig.new(name, model_id, rate_limit, template, options) where options is nil, an array, or another non-hash value.","commonSituations":"Omitting the options argument entirely (nil); YAML config where options is a list; passing JSON string instead of a parsed hash.","solutions":["Pass a Hash (use {} if no options are needed).","Parse JSON option blobs with JSON.parse before constructing the config.","Fix the YAML/JSON config so options is a mapping, not a list."],"exampleFix":"// before\nLlmConfig.new(\"gpt4\", \"gpt-4\", nil, template, nil)\n// after\nLlmConfig.new(\"gpt4\", \"gpt-4\", nil, template, {temperature: 0.7})","handlingStrategy":"type-guard","validationCode":"raise ArgumentError, \"options must be Hash\" unless options.is_a?(Hash)","typeGuard":"def valid_options?(v) = v.is_a?(Hash)","tryCatchPattern":"begin\n  cfg = LlmConfig.new(name, model_id, rate_limit, template, options)\nrescue ArgumentError => e\n  Rails.logger.error(\"Invalid options: #{e.message}\")\n  raise\nend","preventionTips":["Default to {} rather than nil when no options are needed","JSON.parse any serialized options before constructing LlmConfig"],"tags":["argumenterror","validation","llm-config"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}