Skip to content

Pass chunk directly instead of chunk metadata - #63

Merged
y-ken merged 2 commits into
tagomoris:masterfrom
cosmo0920:pass-chunk-directly-instead-of-chunk-metadata
Jun 17, 2026
Merged

Pass chunk directly instead of chunk metadata#63
y-ken merged 2 commits into
tagomoris:masterfrom
cosmo0920:pass-chunk-directly-instead-of-chunk-metadata

Conversation

@cosmo0920

Copy link
Copy Markdown
Contributor

extract_placeholders should be passed chunk instance directly instead of chunk.metadata.

extract_placeholders should be passed chunk instance directly instead of chunk.metadata.

Signed-off-by: Hiroshi Hatake <cosmo0920.oucc@gmail.com>
Signed-off-by: Hiroshi Hatake <cosmo0920.oucc@gmail.com>
@y-ken

y-ken commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this fix, @cosmo0920 — and apologies it sat unreviewed for so long. 🙏

This is correct. In current Fluentd, extract_placeholders(str, chunk) expects the chunk itself; passing chunk.metadata only works through the backward-compat path, which the source explicitly marks as legacy:

# fluentd lib/fluent/plugin/output.rb
def extract_placeholders(str, chunk)
  metadata = if chunk.is_a?(Fluent::Plugin::Buffer::Chunk)
               chunk_passed = true
               chunk.metadata
             else
               chunk_passed = false
               # For existing plugins. Old plugin passes Chunk.metadata instead of Chunk
               chunk
             end
  ...

Besides aligning with the current API, passing the chunk also enables the ${chunk_id} placeholder in database/table — the metadata path logs "${chunk_id} is not allowed in this plugin. Pass Chunk instead of metadata in extract_placeholders's 2nd argument".

I applied this on top of the current code and ran the full suite (including new real-connection integration tests) on Ruby 3.4 / Fluentd 1.19.2 against MySQL 8.4 — all green (18 tests, 63 assertions, 0 failures). The fluentd >= 0.14.22 bump is reasonable as well.

LGTM 👍 I'd like to merge this once the new GitHub Actions CI (#72) lands so it runs through CI; a quick rebase on top of that would be ideal. Thanks again for the fix!

@y-ken

y-ken commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

@tagomoris @toyama0919 I'll organize some of the pending pull requests and issues.

@y-ken
y-ken merged commit d827c90 into tagomoris:master Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants