{"record":{"id":"998288517b908ecc","repo":"fluent/fluentd","slug":"invalid-match-regex","errorCode":null,"errorMessage":"invalid match - regex","messagePattern":"invalid match - regex","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/match.rb","lineNumber":41,"sourceCode":"        GlobMatchPattern.new(str)\n      end\n    end\n  end\n\n  class AllMatchPattern < MatchPattern\n    def match(str)\n      true\n    end\n  end\n\n  class GlobMatchPattern < MatchPattern\n    def initialize(pat)\n      if pat.start_with?('/')\n        if pat.end_with?('/')\n          @regex = Regexp.new(\"\\\\A\"+pat[1..-2]+\"\\\\Z\")\n          return\n        else\n          raise Fluent::ConfigError,  \"invalid match - regex\"\n        end\n      end\n\n      stack = []\n      regex = ['']\n      escape = false\n      dot = false\n\n      i = 0\n      while i < pat.length\n        c = pat[i,1]\n\n        if escape\n          regex.last << Regexp.escape(c)\n          escape = false\n          i += 1\n          next\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/match.rb#L23-L59","documentation":"In <match PATTERN>, a pattern starting with '/' switches GlobMatchPattern into regex mode, where the value must also end with '/' so the content between the slashes becomes an anchored regex (\\A...\\Z wrapped). A leading '/' without a trailing '/' raises this ConfigError at config setup. This rule exists because tags may contain regex metacharacters, so globs and regexes are disambiguated by the slash delimiters.","triggerScenarios":"<match /app.log> (forgot the closing slash); <match /var/log/*> intending a glob for slash-prefixed syslog-style tags; a regex copied from Ruby source (where no delimiters are used) into <match> without wrapping slashes.","commonSituations":"Writing regex tag matches by hand; tags that begin with '/' (syslog, some container log drivers) colliding with delimiter syntax; mixing up glob '*' semantics (matches dots too, unlike shell globs) and switching to regex mid-edit.","solutions":["Close the delimited regex: <match /app\\.log/>","If glob semantics are wanted and the tag does not start with '/', use a plain glob like app.*","For tags that genuinely start with '/', match them with an explicit regex: <match /\\/var\\/log\\/.*/>","Remember the regex is fully anchored; write ^/$ anchors are unnecessary"],"exampleFix":"# before\n<match /app.log>\n  @type stdout\n</match>\n\n# after\n<match /app\\.log/>\n  @type stdout\n</match>","handlingStrategy":"validation","validationCode":"pat = '/app\\.log/'\nraise ArgumentError, 'regex match pattern must end with /' if pat.start_with?('/') && !pat.end_with?('/')\n# also accepts /pat/i, /pat/m\nRegexp.new('\\\\A' + pat[1..-2].gsub(/([im])\\z/, '') + '\\\\Z') rescue raise ArgumentError, 'bad match regex'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write regex match patterns with both delimiters: /pattern/","Prefer globs for simple tag matching and reserve /.../ for real regex needs","Run fluentd --dry-run to validate match patterns before deploy"],"tags":["fluentd","match-pattern","regex","routing","config"],"backgroundTag":"regex-syntax-error","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}