From 8d1104f2a08b6a8219589425aca18fb67856c714 Mon Sep 17 00:00:00 2001 From: Akanksha Trehun Date: Fri, 17 Jul 2026 09:50:31 +0530 Subject: [PATCH] fix(in_tail): fix variable name bugs causing position file leak and NameError Two variable name bugs in the tail input plugin: 1. Line 650: @follow_inode (singular) should be @follow_inodes (plural). Ruby silently returns nil for undefined instance variables, so the condition for cleaning up position file entries during rotation silently degenerates, causing unbounded growth of stale entries. 2. Line 709: tail_watcher should be tw (the method parameter). This causes a NameError crash when emit_unmatched_lines is enabled with path_key in multiline mode. Signed-off-by: Akanksha Trehun --- lib/fluent/plugin/in_tail.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fluent/plugin/in_tail.rb b/lib/fluent/plugin/in_tail.rb index 3d32d6a057..4eaff98bab 100644 --- a/lib/fluent/plugin/in_tail.rb +++ b/lib/fluent/plugin/in_tail.rb @@ -647,7 +647,7 @@ def detach_watcher(tw, ino, close_io = true) tw.close if close_io - if @pf && tw.unwatched && (@follow_inode || !@tails[tw.path]) + if @pf && tw.unwatched && (@follow_inodes || !@tails[tw.path]) target_info = TargetInfo.new(tw.path, ino) @pf.unwatch(target_info) end @@ -751,7 +751,7 @@ def convert_line_to_event(line, es, tail_watcher) else if @emit_unmatched_lines record = {'unmatched_line' => line} - record[@path_key] ||= tail_watcher.path unless @path_key.nil? + record[@path_key] ||= tw.path unless @path_key.nil? es.add(Fluent::EventTime.now, record) end log.warn { "pattern not matched: #{line.inspect}" }