{"record":{"id":"ac91be27ad53c14e","repo":"ankane/chartkick","slug":"invalid-k","errorCode":null,"errorMessage":"Invalid #{k}","messagePattern":"Invalid #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/chartkick/helper.rb","lineNumber":81,"sourceCode":"          nonce = nil\n        end\n      end\n      nonce_html = nonce ? \" nonce=\\\"#{ERB::Util.html_escape(nonce)}\\\"\" : nil\n\n      # html vars\n      html_vars = {\n        id: element_id,\n        height: height,\n        width: width,\n        # don't delete loading option since it needs to be passed to JS\n        loading: options[:loading] || \"Loading...\"\n      }\n\n      [:height, :width].each do |k|\n        # limit to alphanumeric and % for simplicity\n        # this prevents things like calc() but safety is the priority\n        # dot does not need escaped in square brackets\n        raise ArgumentError, \"Invalid #{k}\" unless /\\A[a-zA-Z0-9%.]*\\z/.match?(html_vars[k])\n      end\n\n      html_vars.each_key do |k|\n        # escape all variables\n        # we already limit height and width above, but escape for safety as fail-safe\n        # to prevent XSS injection in worse-case scenario\n        html_vars[k] = ERB::Util.html_escape(html_vars[k])\n      end\n\n      html = (options.delete(:html) || %(<div id=\"%{id}\" style=\"height: %{height}; width: %{width}; text-align: center; color: #999; line-height: %{height}; font-size: 14px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif;\">%{loading}</div>)) % html_vars\n\n      # js vars\n      js_vars = {\n        type: klass.to_json,\n        id: element_id.to_json,\n        data: data_source.respond_to?(:chart_json) ? data_source.chart_json : data_source.to_json,\n        options: options.to_json\n      }","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/ankane/chartkick/blob/2c6cd4eb6275021c7b87d8e52767cde3bec396d2/lib/chartkick/helper.rb#L63-L99","documentation":"Error \"Invalid #{k}\" thrown in ankane/chartkick.","triggerScenarios":"Thrown at lib/chartkick/helper.rb:81 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c6cd4eb6275021c7b87d8e52767cde3bec396d2","analyzedAt":"2026-08-21T19:06:48.947Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}