{"record":{"id":"7e37f9682ab38ba1","repo":"instructure/canvas-lms","slug":"options-still-contain-placeholder-remaining-placeholder-0","errorCode":null,"errorMessage":"Options still contain placeholder: #{remaining_placeholder[0]}","messagePattern":"Options still contain placeholder: #(.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"app/models/llm_config.rb","lineNumber":53,"sourceCode":"    substitutions.each do |placeholder_prefix, sub_value|\n      new_template.gsub!(\"<#{placeholder_prefix}_PLACEHOLDER>\") { sub_value.to_s }\n    end\n\n    if (remaining_placeholder = new_template.match(/<\\w+_PLACEHOLDER>/))\n      raise ArgumentError, \"Template still contains placeholder: #{remaining_placeholder[0]}\"\n    end\n\n    new_options = options.deep_dup\n\n    new_options.each do |key, value|\n      substitutions.each do |placeholder_prefix, sub_value|\n        new_options[key] = value.gsub(\"<#{placeholder_prefix}_PLACEHOLDER>\", sub_value.to_s) if value.is_a?(String)\n      end\n    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":35,"sourceCodeEnd":70,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/llm_config.rb#L35-L70","documentation":"After substituting placeholders into deep-duped options, generate_prompt_and_options verifies no String option value still contains a '<\\w+_PLACEHOLDER>' token and raises ArgumentError otherwise. It catches option values (e.g. system messages, parameters) referencing placeholders absent from the substitutions hash.","triggerScenarios":"Calling generate_prompt_and_options where an entry in the config's options hash is a String containing '<FOO_PLACEHOLDER>' and substitutions has no :FOO key.","commonSituations":"Options templates referencing placeholders only defined for the prompt template; typos in option placeholder names; nested options updated independently from substitutions.","solutions":["Supply the missing key in the substitutions hash matching the placeholder in the option string.","Correct or remove the placeholder in the options hash of the LlmConfig definition.","If a literal '<X_PLACEHOLDER>' string is intended, escape/reword it so it does not match the placeholder pattern."],"exampleFix":"// before\noptions: { system: \"You assist <ROLE_PLACEHOLDER>\" }  # called without :ROLE\n// after\ncfg.generate_prompt_and_options(role: \"a tutor\", ...)","handlingStrategy":"validation","validationCode":"config.options.each_value do |v|\n  next unless v.is_a?(String)\n  bad = v.scan(/<(\\w+)_PLACEHOLDER>/).flatten - substitutions.keys.map(&:to_s)\n  raise \"unsubstituted option placeholders: #{bad.join(',')}\" unless bad.empty?\nend","typeGuard":null,"tryCatchPattern":"begin\n  prompt, opts = config.generate_prompt_and_options(substitutions)\nrescue ArgumentError => e\n  Rails.logger.error(\"LLM options placeholder error: #{e.message}\")\n  raise\nend","preventionTips":["Derive option placeholder names from the same constant set as template placeholders","Add config-level tests that render every LlmConfig with a full substitutions hash"],"tags":["argumenterror","template","llm"],"backgroundTag":"missing-required-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"}