Skip to content

pack: bound JSON conversion depth and handle packing failures - #12446

Open
edsiper wants to merge 3 commits into
masterfrom
fix/ingestor-json-depth
Open

edsiper wants to merge 3 commits into
masterfrom
fix/ingestor-json-depth

Conversation

@edsiper

@edsiper edsiper commented Sep 19, 2026

Copy link
Copy Markdown
Member

Bound shared JSON conversion before recursive descent and propagate MessagePack packing failures. This protects MQTT and inputs using a configured JSON parser, and cleans up partial output when a record cannot be converted.

Validation: Pack and JSON-parser CTest targets passed. The nesting regression fails against the original converter and passes with this change. Defensive network cases for MQTT, TCP/UDP parser and streaming modes, HTTP, Splunk and Forward passed normally and under strict Valgrind; the focused pack boundary test is Valgrind-clean.

Focused integration commands (run against the combined validation build containing these fixes):

FLUENT_BIT_BINARY=$PWD/build/bin/fluent-bit tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/security_ingestors -q
VALGRIND=1 VALGRIND_STRICT=1 FLUENT_BIT_BINARY=$PWD/build/bin/fluent-bit tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/security_ingestors -q

Relevant internal CTest targets and focused Valgrind checks also passed. Full PR-range commit-prefix lint, DCO and whitespace checks passed against fetched master. Code and regression tests are separate commits.

Compatibility: JSON containers beyond the configured MessagePack nesting budget (64 in this build) are rejected. Configured parser inputs retain their existing fallback behavior. Public interfaces are unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of deeply nested JSON and MessagePack payloads by safely limiting nesting depth.
    • Prevented ingestion failures and process instability when malformed or excessively nested records are received.
    • Added safeguards against oversized inputs that could cause length-calculation errors.
    • Improved error handling during JSON-to-MessagePack conversion so failed conversions clean up safely and report an error.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: c7ea8ca7-ddb0-492d-a687-443c21f02f47

📥 Commits

Reviewing files that changed from the base of the PR and between a48daa6 and 2c8bf0a.

📒 Files selected for processing (3)
  • src/flb_pack.c
  • tests/integration/scenarios/security_ingestors/tests/test_security_ingestors.py
  • tests/internal/pack.c

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The YYJSON-to-MessagePack path now limits nesting, propagates packing failures, prevents allocation-size overflow, and cleans up errors. Unit and integration tests cover depth limits and recovery across network ingestion protocols.

Changes

YYJSON nesting and recovery

Layer / File(s) Summary
Conversion depth and error handling
src/flb_pack.c
yyjson_val_to_msgpack returns errors, limits container depth, and checks MessagePack packing calls. Input length validation prevents allocation overflow. Failed conversions release allocated resources.
Unit coverage for depth limits
tests/internal/pack.c
Tests cover map, array, and mixed nesting at and above MSGPACK_EMBED_STACK_SIZE.
Network ingestion recovery coverage
tests/integration/scenarios/security_ingestors/tests/test_security_ingestors.py
Integration tests send deeply nested records through multiple protocols and verify that Fluent Bit remains running and shuts down cleanly.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~30 minutes

Change: Bug fix

Suggested reviewers: cosmo0920

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: limiting JSON conversion depth and handling MessagePack packing failures.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-19T15:36:38.358159Z 2c8bf0a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c8bf0a15d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +46 to +47
memory = os.environ.get("VALGRIND") == "1"
if memory:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor macOS Leaks mode in the new daemon

When this scenario runs on macOS via run_tests.py --leaks-strict, the runner sets LEAKS and LEAKS_STRICT, but this condition remains false and launches Fluent Bit directly. Consequently, the required memory-safety pass can report success without running Leaks or checking its result; handle LEAKS here or use the suite's existing memory-check wrapper.

AGENTS.md reference: AGENTS.md:L101-L105

Useful? React with 👍 / 👎.

@UgurTheG

Copy link
Copy Markdown

High likely a duplicate of #12313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants