{"record":{"id":"1acae4466e2d82c5","repo":"fluent/fluentd","slug":"basename-should-not-include","errorCode":null,"errorMessage":"basename should not include `/`","messagePattern":"basename should not include `/`","errorType":"validation","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/out_secondary_file.rb","lineNumber":44,"sourceCode":"    PLACEHOLDER_REGEX = /\\${(tag(\\[\\d+\\])?|[\\w.@-]+)}/\n\n    desc \"The directory path of the output file.\"\n    config_param :directory, :string\n    desc \"The basename of the output file.\"\n    config_param :basename, :string, default: \"dump.bin\"\n    desc \"The flushed chunk is appended to existence file or not.\"\n    config_param :append, :bool, default: false\n    config_param :compress, :enum, list: [:text, :gzip], default: :text\n\n    def configure(conf)\n      super\n\n      unless @as_secondary\n        raise Fluent::ConfigError, \"This plugin can only be used in the <secondary> section\"\n      end\n\n      if @basename.include?(\"/\")\n        raise Fluent::ConfigError, \"basename should not include `/`\"\n      end\n\n      @path_without_suffix = File.join(@directory, @basename)\n      validate_compatible_with_primary_buffer!(@path_without_suffix)\n\n      @suffix = case @compress\n                when :text\n                  \"\"\n                when :gzip\n                  \".gz\"\n                end\n\n      test_path = @path_without_suffix\n      unless Fluent::FileUtil.writable_p?(test_path)\n        raise Fluent::ConfigError, \"out_secondary_file: `#{@directory}` should be writable\"\n      end\n\n      @dir_perm = system_config.dir_permission || Fluent::DEFAULT_DIR_PERMISSION","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/out_secondary_file.rb#L26-L62","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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`"],"exampleFix":"# before\ndirectory /var/log/fluent/buffer\nbasename dump/2024/daily.bin\n\n# after\ndirectory /var/log/fluent/buffer/2024\nbasename daily.bin","handlingStrategy":"validation","validationCode":"basename = conf['basename'] || 'dump.bin'\nraise \"basename must not contain '/': #{basename}\" if basename.include?('/')\n# put path components only in directory:\ndirectory = conf['directory'] or raise 'directory is required'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["fluentd","secondary-file","path-validation","configuration"],"backgroundTag":"invalid-filename","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}