{"record":{"id":"5eefb7f38897fa89","repo":"fluent/fluentd","slug":"out-secondary-file-basename-or-directory-has-an-i-5eefb7","errorCode":null,"errorMessage":"out_secondary_file: basename or directory has an incompatible placeholder #{ph}, remove tag placeholder, like `${tag}`, from basename or directory","messagePattern":"out_secondary_file: basename or directory has an incompatible placeholder #(.+?), remove tag placeholder, like `(.+?)`, from basename or directory","errorType":"validation","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/out_secondary_file.rb","lineNumber":102,"sourceCode":"            gz = Zlib::GzipWriter.new(f)\n            chunk.write_to(gz)\n            gz.close\n          }\n        end\n      end\n    end\n\n    private\n\n    def validate_compatible_with_primary_buffer!(path_without_suffix)\n      placeholders = path_without_suffix.scan(PLACEHOLDER_REGEX).flat_map(&:first) # to trim suffix [\\d+]\n\n      if !@chunk_key_time && has_time_format?(path_without_suffix)\n        raise Fluent::ConfigError, \"out_secondary_file: basename or directory has an incompatible placeholder, remove time formats, like `%Y%m%d`, from basename or directory\"\n      end\n\n      if !@chunk_key_tag && (ph = placeholders.find { |placeholder| placeholder.match?(/tag(\\[\\d+\\])?/) })\n        raise Fluent::ConfigError, \"out_secondary_file: basename or directory has an incompatible placeholder #{ph}, remove tag placeholder, like `${tag}`, from basename or directory\"\n      end\n\n      vars = placeholders.reject { |placeholder| placeholder.match?(/tag(\\[\\d+\\])?/) || (placeholder == 'chunk_id') }\n\n      if ph = vars.find { |v| !@chunk_keys.include?(v) }\n        raise Fluent::ConfigError, \"out_secondary_file: basename or directory has an incompatible placeholder #{ph}, remove variable placeholder, like `${varname}`, from basename or directory\"\n      end\n    end\n\n    def has_time_format?(str)\n      str != Time.now.strftime(str)\n    end\n\n    def generate_path(path_without_suffix)\n      if @append\n        path = \"#{path_without_suffix}#{@suffix}\"\n        synchronize_path(path) do\n          yield path","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/out_secondary_file.rb#L84-L120","documentation":"SecondaryFileOutput#configure found a ${tag} or ${tag[n]} placeholder in directory/basename (matched by PLACEHOLDER_REGEX) but the primary buffer has no `tag` chunk key (@chunk_key_tag false), so the tag value is unavailable when the secondary generates its file path — Fluent::ConfigError at configure time. Placeholders in the secondary must be a subset of what the primary buffer keys can supply.","triggerScenarios":"Primary `<buffer>` (empty, keyed only on time or variables) with secondary_file `directory /var/log/dump/${tag}` or `basename ${tag}.bin`.","commonSituations":"Adding tag-based file names for debugging without updating the primary's buffer keys; primary using `<buffer time>` only (common for aggregation setups where tag was dropped for chunk sharing).","solutions":["Add `tag` to the primary buffer keys: `<buffer tag>` or `<buffer time, tag>`","Or remove the ${tag} placeholder from directory/basename (use ${chunk_id}, which is always allowed)","Note ${tag[0]} etc. also require the tag key, not just a slice"],"exampleFix":"# before\n<match **>\n  @type forward\n  <buffer time>\n    timekey 1h\n  </buffer>\n  <secondary>\n    @type secondary_file\n    directory /var/log/dump/${tag}\n  </secondary>\n</match>\n\n# after\n<match **>\n  @type forward\n  <buffer time, tag>\n    timekey 1h\n  </buffer>\n  <secondary>\n    @type secondary_file\n    directory /var/log/dump/${tag}\n  </secondary>\n</match>","handlingStrategy":"validation","validationCode":"# Check: ${tag} placeholders require a tag chunk key\nbuffer = match_element.elements.find { |e| e.name == 'buffer' }\nkeys = buffer ? buffer.arg.to_s.split(',').map(&:strip) : []\npath = File.join(directory, basename || 'dump.bin')\nhas_tag_ph = path.match?(/\\$\\{tag(\\[\\d+\\])?}/)\nraise '${tag} placeholder needs <buffer tag> in primary' if has_tag_ph && !keys.include?('tag')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Every ${tag}/${tag[n]} in directory or basename must be backed by `tag` in the primary <buffer> keys","${chunk_id} is always safe when you just need unique names without extra chunk keys","When changing the primary buffer keys (e.g. dropping tag for chunk sharing), re-validate the secondary path"],"tags":["fluentd","secondary-file","buffer","placeholder","tag","configuration"],"backgroundTag":"buffer-key-placeholder-mismatch","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}