parser_syslog: string parser raises NoMethodError on some malformed messages
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #5589 @yuminn-k による — マージ済み
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- ruby
調査の方向性
まずRFC3164とRFC5424の文字列パーサーのパスを読み、ここで説明されている正規表現パーサーの動作と、不正なヘッダーの処理を比較してください。RFC5424のUTF-8行を含め、issueにある3つの入力を再現してください。完了条件は、文字列パーサーが例外を発生させず、説明どおりに入力が解析されるか、一致しない行として出力されることです。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With parser_engine string, parser_syslog raises NoMethodError on some malformed messages that are not truncated. #5584 covers truncated messages. These are different code paths.
- RFC3164: the ident ends with
]but has no[. The parser subtracts from thenilresult oftext.index('[', cursor). - RFC5424: the header contains a non-ASCII character, STRUCTURED-DATA is
-, and there is no MSG. The parser comparescursor, a character index, withtext.bytesize. They differ, so it slices past the end and callschomp!onnil.
| Input | message_format |
string | regexp |
|---|---|---|---|
<14>Apr 25 16:43:29 host app]: message |
rfc3164 |
undefined method '-' for nil |
ident app], message message |
<14>Apr 25 16:43:29 host app] message |
rfc3164 |
undefined method '-' for nil |
ident app], message message |
<14>1 2026-04-25T16:43:29Z ホスト app 123 ID - (UTF-8) |
rfc5424 |
undefined method 'chomp!' for nil |
unmatched |
Because the parser raises, in_tail drops these lines with invalid line found even when emit_unmatched_lines is enabled. The second case needs a UTF-8 string, for example in_tail with encoding UTF-8 or filter_parser on a UTF-8 field.
To Reproduce
-
Create
/tmp/rfc3164.logwith these lines:<14>Apr 25 16:43:29 host app]: message <14>Apr 25 16:43:29 host app] message -
Create
/tmp/rfc5424.logwith this line in UTF-8:<14>1 2026-04-25T16:43:29Z ホスト app 123 ID - -
Run Fluentd with the configuration below.
Expected behavior
The parser does not raise. The RFC3164 lines are parsed as with parser_engine regexp, or reported as unmatched. The RFC5424 line is emitted as unmatched_line, as with parser_engine regexp.
Actual: all three lines are dropped with invalid line found.
Your Environment
- Fluentd version: 1.20.1 (master at f55db4b1)
- Package version: N/A (from source)
- Operating system: CachyOS
- Kernel version: 7.3.1-1-cachyos
- Ruby: 4.0.9
Your Configuration
<source>
@type tail
path /tmp/rfc3164.log
pos_file /tmp/rfc3164.log.pos
read_from_head true
emit_unmatched_lines true
tag rfc3164
<parse>
@type syslog
message_format rfc3164
with_priority true
parser_engine string
</parse>
</source>
<source>
@type tail
path /tmp/rfc5424.log
pos_file /tmp/rfc5424.log.pos
read_from_head true
emit_unmatched_lines true
encoding UTF-8
tag rfc5424
<parse>
@type syslog
message_format rfc5424
with_priority true
parser_engine string
</parse>
</source>
<match **>
@type stdout
</match>
Your Error Log
[warn]: invalid line found file="/tmp/rfc3164.log" line="<14>Apr 25 16:43:29 host app]: message" error="undefined method '-' for nil"
[warn]: invalid line found file="/tmp/rfc3164.log" line="<14>Apr 25 16:43:29 host app] message" error="undefined method '-' for nil"
[warn]: invalid line found file="/tmp/rfc5424.log" line="<14>1 2026-04-25T16:43:29Z ホスト app 123 ID -" error="undefined method 'chomp!' for nil"
Additional context
The RFC3164 case exists since v1.7.1. The RFC5424 case exists since v1.11.0.
- 主要言語
- Ruby
- スター
- 13.6k
- フォーク
- 1.4k
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 61
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluent/fluentd のほかの issue
-
in_tcp: skip emitting an empty event stream when a read has no complete message対応中かも @lbarrosby が 1 日前に担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
in_tcp, in_syslog: a non-ASCII delimiter closes the connection with Encoding::CompatibilityError対応中かも @1AbdullahButt が 1 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
メンテナーはふだん 1 日以内に返信
-
bug enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
fluent/fluentd#5494 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
BufferChunkOverflowError inside @ERROR loops forever - no buffer parameter can stop it再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
fluent/fluentd#5462 · コメント 8 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
rubys/roundhouse#1950 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
`Time.at(t, in: nil)` returns UTC instead of the local time (or the time zone of `t`), unlike CRubyオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
swombat/souls-house#825 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信