Skip to content

Comments

Implement chunked encoding for TXT records in DNS Message Record clas…#39

Merged
loks0n merged 3 commits intomainfrom
fix-txt-chunk-error
Feb 18, 2026
Merged

Implement chunked encoding for TXT records in DNS Message Record clas…#39
loks0n merged 3 commits intomainfrom
fix-txt-chunk-error

Conversation

@eldadfux
Copy link
Member

@eldadfux eldadfux commented Feb 18, 2026

…s and add corresponding unit tests for multi-chunk handling.

Summary by CodeRabbit

  • Bug Fixes

    • TXT records now support longer data by automatically splitting RDATA into 255-byte chunks during encoding and correctly reconstructing it during decoding.
  • Tests

    • Added comprehensive tests covering multi-chunk TXT encoding/decoding, including various lengths and round-trip verification.

…s and add corresponding unit tests for multi-chunk handling.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Warning

Rate limit exceeded

@eldadfux has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Walkthrough

This change updates TXT record handling to support multi-chunk RDATA encoding: TXT data is split into chunks of up to 255 bytes, each prefixed with a one-byte length, and the encoder concatenates those length-prefixed chunks. Decoding concatenates multiple chunks back into the original RDATA. Unit tests were added to cover encoding and decoding round-trips for multi-chunk TXT records and to validate chunk sizes and RDLENGTH for long TXT payloads.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: implementing chunked encoding for TXT records in the DNS Message Record class, which aligns with the changeset that modifies TXT record encoding logic and adds comprehensive test coverage.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-txt-chunk-error

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/DNS/Message/Record.php`:
- Around line 450-464: The TXT encoder in the TYPE_TXT branch of Record.php
builds no character-strings when $this->rdata is empty, producing RDLENGTH=0
which breaks decode(); change the logic in the TYPE_TXT case (in the encode
method handling $this->rdata, using self::MAX_TXT_CHUNK) so that if
strlen($this->rdata) === 0 you emit a single zero-length character-string
(chr(0)) instead of an empty string; leave the existing chunking behavior
unchanged for non-empty rdata.

In `@tests/unit/DNS/Message/RecordTest.php`:
- Around line 361-382: The test testEncodeTxtRecordWithMultipleChunks
incorrectly expects two 5-byte TXT chunks and an RDLENGTH of 10 for rdata
'helloworld' even though Record::encode() will emit a single chunk (length byte
+ payload) for any chunk <= 255 bytes; fix the test by updating the expected
encoding to a single TXT chunk (length byte 0x0A followed by "helloworld" and
RDLENGTH = 11) or change the test to use an rdata >255 bytes to actually
exercise multi-chunk behavior (keep references to Record::TYPE_TXT,
Record::CLASS_IN, and the Record::encode() call when updating assertions).

…or for exactly 256 bytes of rdata, ensuring correct split into two chunks and verifying round-trip encoding/decoding.
…haracter-string, ensuring compliance with RFC 1035.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/unit/DNS/Message/RecordTest.php`:
- Around line 374-376: The failing CI is due to trailing whitespace on the blank
line after the $encoded = $record->encode(); statement in RecordTest
(tests/unit/DNS/Message/RecordTest.php); remove the trailing spaces from that
blank line (or delete the blank line) so the file has no whitespace-only lines,
and re-run PHP Pint (./vendor/bin/pint --config pint.json or pint --write) to
ensure the file conforms to PSR-12.

@loks0n loks0n merged commit 8bac7d6 into main Feb 18, 2026
5 checks passed
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