{"record":{"id":"0d98d772540448db","repo":"fluent/fluentd","slug":"invalid-regexp-missing-right-slash-str","errorCode":null,"errorMessage":"invalid regexp: missing right slash: #{str}","messagePattern":"invalid regexp: missing right slash: #(.+?)","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/config/types.rb","lineNumber":90,"sourceCode":"        # Current parser passes comment without actual values, e.g. \"param #foo\".\n        # parser should pass empty string in this case but changing behaviour may break existing environment so keep parser behaviour. Just ignore comment value in boolean handling for now.\n        if str.respond_to?(:start_with?) && str.start_with?('#')\n          true\n        elsif opts[:strict]\n          raise Fluent::ConfigError, \"#{name}: invalid bool value: #{str}\"\n        else\n          nil\n        end\n      end\n    end\n\n    def self.regexp_value(str, opts = {}, name = nil)\n      return nil unless str\n\n      return Regexp.compile(str) unless str.start_with?(\"/\")\n      right_slash_position = str.rindex(\"/\")\n      if right_slash_position < str.size - 3\n        raise Fluent::ConfigError, \"invalid regexp: missing right slash: #{str}\"\n      end\n      options = str[(right_slash_position + 1)..-1]\n      option = 0\n      option |= Regexp::IGNORECASE if options.include?(\"i\")\n      option |= Regexp::MULTILINE if options.include?(\"m\")\n      Regexp.compile(str[1...right_slash_position], option)\n    end\n\n    def self.string_value(val, opts = {}, name = nil)\n      return nil if val.nil?\n\n      v = val.to_s\n      v = v.frozen? ? v.dup : v # config_param can't assume incoming string is mutable\n      v.force_encoding(Encoding::UTF_8)\n    end\n\n    STRING_TYPE = Proc.new { |val, opts = {}, name = nil|\n      Config.string_value(val, opts, name)","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/config/types.rb#L72-L108","documentation":"For parameters of the :regexp type, a value starting with '/' is treated as a delimited regex literal: the closing '/' must appear within the last three characters so that at most two flag characters ('i', 'm') may follow it. regexp_value computes the last '/' via rindex and raises this ConfigError when that slash sits too far from the end, i.e. the literal is effectively unterminated. Without a leading slash the whole string is compiled directly as a regex, so only the delimited form has this syntax requirement.","triggerScenarios":"config_param :pattern, :regexp with a value like '/app\\.log' (opening slash but no closing slash), '/logs?' with no terminator, or a leading-slash tag glob written as '/var/log/*' that is misparsed as an unterminated regex literal.","commonSituations":"Forgetting the trailing slash in <match>-adjacent regex params; tags that literally start with '/' (syslog-style, some Docker logging drivers) colliding with the delimited-regex syntax; hand-editing configs where the glob was copied from a path.","solutions":["Close the literal: '/app\\.log/' or with flags '/app\\.log/i'","If the pattern is not meant to be a delimited regex, drop the leading slash so the raw string is compiled as-is (only flags are then unavailable)","For tags that genuinely start with '/', write a full delimited regex that matches them, e.g. '/\\/var\\/log\\/.*/'","Double-check escaping: the content between the slashes is passed to Regexp.compile verbatim"],"exampleFix":"# before\n# config_param :exclude, :regexp\n<match demo.**>\n  @type stdout\n  exclude /debug\n</match>\n\n# after\n<match demo.**>\n  @type stdout\n  exclude /debug/\n</match>","handlingStrategy":"validation","validationCode":"s = raw_value.to_s\nterminated = !s.start_with?('/') || (idx = s.rindex('/')) && idx >= s.size - 3\nraise ArgumentError, \"unterminated regexp literal: #{s.inspect}\" unless terminated\nRegexp.compile(s[1...s.rindex('/')]) rescue raise ArgumentError, \"bad regexp body: #{s.inspect}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write delimited regexes as /pattern/ or /pattern/i","Remember any value starting with '/' is regex mode; use globs without leading slash otherwise","Test regex params in a --dry-run load before deploying"],"tags":["fluentd","config","regexp","type-conversion"],"backgroundTag":"regex-parse-error","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}