fluent/fluentd · error · Fluent::ConfigError
basename should not include `/`
Error message
basename should not include `/`
What it means
SecondaryFileOutput#configure rejects a `basename` containing `/` (Fluent::ConfigError at configure time). The plugin joins directory + basename into the output path, and a slash inside basename would smuggle extra path components into the file name (ambiguity and escape from the intended directory), so the path structure must be expressed entirely via the `directory` param.
Source
Thrown at lib/fluent/plugin/out_secondary_file.rb:44
PLACEHOLDER_REGEX = /\${(tag(\[\d+\])?|[\w.@-]+)}/
desc "The directory path of the output file."
config_param :directory, :string
desc "The basename of the output file."
config_param :basename, :string, default: "dump.bin"
desc "The flushed chunk is appended to existence file or not."
config_param :append, :bool, default: false
config_param :compress, :enum, list: [:text, :gzip], default: :text
def configure(conf)
super
unless @as_secondary
raise Fluent::ConfigError, "This plugin can only be used in the <secondary> section"
end
if @basename.include?("/")
raise Fluent::ConfigError, "basename should not include `/`"
end
@path_without_suffix = File.join(@directory, @basename)
validate_compatible_with_primary_buffer!(@path_without_suffix)
@suffix = case @compress
when :text
""
when :gzip
".gz"
end
test_path = @path_without_suffix
unless Fluent::FileUtil.writable_p?(test_path)
raise Fluent::ConfigError, "out_secondary_file: `#{@directory}` should be writable"
end
@dir_perm = system_config.dir_permission || Fluent::DEFAULT_DIR_PERMISSIONView on GitHub (pinned to dd45c6e18d)
Solutions
- Move all directory parts into `directory`: `directory /var/log/fluent/dump/2024` + `basename daily.dump`
- For dynamic subdirectories, use placeholders on `directory` matched to the primary buffer's chunk keys (e.g. `<buffer time>` + directory `/var/log/dump/%Y%m%d`)
- Re-check with `fluentd --dry-run`
Example fix
# before directory /var/log/fluent/buffer basename dump/2024/daily.bin # after directory /var/log/fluent/buffer/2024 basename daily.bin
Defensive patterns
Strategy: validation
Validate before calling
basename = conf['basename'] || 'dump.bin'
raise "basename must not contain '/': #{basename}" if basename.include?('/')
# put path components only in directory:
directory = conf['directory'] or raise 'directory is required' Prevention
- Convention: directory holds ALL path structure; basename is a bare file name
- Migrating from @type file: split its `path` at the last slash — dirname→directory, basename→basename
- For date-partitioned output use placeholders on directory (with matching buffer keys), never slashes in basename
When it happens
Trigger: `basename 2024/daily.dump` or `basename backups/dump.bin` — any forward slash in the value. Backslashes are not checked, but on Linux they are legal filename characters, not separators.
Common situations: Trying to add date-partitioned subdirectories via basename instead of directory; migrating a template like path/to/file from @type file (where path accepts slashes) to secondary_file's directory/basename split.
Related errors
- This plugin can only be used in the <secondary> section
- out_secondary_file: `#{@directory}` should be writable
- out_secondary_file: basename or directory has an incompatibl
- out_secondary_file: basename or directory has an incompatibl
- out_secondary_file: basename or directory has an incompatibl
AI-assisted analysis of fluent/fluentd@dd45c6e18d (2026-08-21).
Data as JSON: /api/errors/1acae4466e2d82c5.
Report an issue: GitHub.