Skip to content

Comments

[homekit.binding] Increase maximum permitted HTTP content length#20212

Merged
jlaur merged 1 commit intoopenhab:mainfrom
andrewfg:homekit-max-content-length
Feb 11, 2026
Merged

[homekit.binding] Increase maximum permitted HTTP content length#20212
jlaur merged 1 commit intoopenhab:mainfrom
andrewfg:homekit-max-content-length

Conversation

@andrewfg
Copy link
Contributor

@andrewfg andrewfg commented Feb 11, 2026

The current maximum permitted HTTP content length is 64k bytes. However during testing I found one accessory that produces valid payloads over 100k bytes. This PR increases the maximum permitted HTTP content length limit from 64k bytes to 256k bytes.

Signed-off-by: Andrew Fiddian-Green software@whitebear.ch

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@andrewfg andrewfg self-assigned this Feb 11, 2026
@andrewfg andrewfg added the enhancement An enhancement or new feature for an existing add-on label Feb 11, 2026
@andrewfg andrewfg requested review from a team and Copilot February 11, 2026 11:29
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

@jlaur jlaur merged commit e731d52 into openhab:main Feb 11, 2026
6 of 7 checks passed
@jlaur jlaur added this to the 5.2 milestone Feb 11, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the HomeKit binding’s HTTP payload parser to accept larger valid HomeKit HTTP bodies by increasing the maximum permitted content length.

Changes:

  • Increased the maximum allowed HTTP content length from 64 KiB to 256 KiB.
  • Enhanced exception messages to include actual/maximum sizes when payloads exceed the limit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (chunkDataBuffer.size() > MAX_CONTENT_LENGTH) {
throw new IOException("Chunked data exceeds maximum allowed size");
throw new IOException("Chunked data size %d exceeds maximum allowed %d"
.formatted(contentBuffer.size(), MAX_CONTENT_LENGTH));
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The chunked-size limit check is performed on chunkDataBuffer.size(), but the exception message formats contentBuffer.size(). This can report an unrelated (often smaller) value and make diagnosing oversize chunked payloads confusing. Use the same buffer size in the message as the one being validated (or report both if that's intended).

Suggested change
.formatted(contentBuffer.size(), MAX_CONTENT_LENGTH));
.formatted(chunkDataBuffer.size(), MAX_CONTENT_LENGTH));

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops! @jlaur you were too fast ;) but I will fix it..

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I missed that, AI beats me spotting such things. 😉 I don't know who requested the Copilot review, but I don't have access to do that myself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

who requested the Copilot review

I did it myself.

but I don't have access to do that myself

I think any GitHub user can register their account to allow Copilot. It gives you a certain number of gratis requests per month which is sufficient (most months) for a binding contributor like me. However you may find that as a reviewer you may hit the limit sooner. But it is worth having anyway..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PS I added the fix into #20209 which reverts the 11 digit pairing code stuff, and instead repurposes the PR for two minor tweaks.

andrewfg added a commit to andrewfg/openhab-addons that referenced this pull request Feb 11, 2026
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@andrewfg andrewfg changed the title [binding.homekit] Increase maximum permitted HTTP content length [homekit.binding] Increase maximum permitted HTTP content length Feb 14, 2026
@andrewfg andrewfg deleted the homekit-max-content-length branch February 15, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature for an existing add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants