Repository navigation
notify: pack Feishu digests against the serialized request body - #174
Merged
Merged
Conversation
A Feishu digest sends every item as its own card element. The packing counted the text of each line only, not the element around it (about 52 bytes of JSON per item, plus whatever the encoding escapes) nor the rest of the body beyond a fixed 320-byte reserve. A digest of 500 short lines therefore left as a single request of 41846 bytes, while Feishu rejects a request body over 20 KB as a whole. feishuCard now adds whole items while the request body, measured as it is serialized, stays within feishuMaxCardBytes: each item element by its JSON encoding, the card around the items (header, intro, platform link) by encoding it for the number of items kept, and what Send adds around the card (msg_type, timestamp, sign) as feishuEnvelopeBytes, which the new test pins to the bytes on the wire. Unchanged: the first item of a digest is always kept and its text is truncated to the same budget, single pushes are built as before, and the other channels still pack with packItemCount.
This was referenced Nov 10, 2026
Closed
Merged
usinfosec
pushed a commit
to usinfosec/ARTEX
that referenced
this pull request
Nov 17, 2026
This was referenced Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Feishu digest packing now measures the request body as it is serialized, so a digest stays within
feishuMaxCardBytes(16000).feishuCardadds whole items while the body fits, counting:Sendadds around the card (msg_type,timestamp,sign) as the new constantfeishuEnvelopeBytes = 113. The new test checks this constant against the bytes on the wire.Only
notify/feishu.goandnotify/pack_test.gochange. The digest branch offeishuCardno longer callspackItemCount; DingTalk, WeCom and Telegram still do, andpackItemCountitself is untouched.Why
Left open in #172 ("A Feishu digest of several hundred short items can therefore still exceed 20 KB"). Every digest line is sent as its own card element, about 52 bytes of JSON around the text. The packing counted the text of each line only, against a fixed 320-byte reserve for everything else. Feishu rejects a request body over 20 KB as a whole, so such a digest would not arrive at all.
Before / after
Request body sent on the wire by
feishuChannel.Send(signed), 500-item digest, measured by the new test:main(3b6eb2f)<,>,&,"The largest body on this branch is 15980 bytes. The 47206-byte figure quoted for
maincame from a different set of lines; with the lines of this test the same case measures 41846.Behaviour kept
Sendreports equals the lines in the body.feishuMaxCardBytes - markdownReservedBytes). A digest whose first item alone is oversized can therefore still exceed 16000, as onmain(16370 bytes in the existingTestFeishuUntruncatedItemStaysWithinBodyLimit, which asserts 20000). This change does not touch that guard.To review
feishuEnvelopeBytesassumes a 10-digit Unix timestamp.Verification
Run in WSL (Go 1.26.10, linux/amd64) on commit 542582e.
go build ./...: pass.go vet ./...: pass.go test ./notify/ -count=1 -race:ok(1.299s).TestFeishuDigestBodiesStayWithinCardLimit(no database, three subtests): pass. The existing Feishu tests pass unchanged.notify/feishu.gofrommain(plus the constant so the test compiles): the test fails in all three subtests at 41846, 31598 and 33247 bytes.Not verified:
go test ./...was not run; theserveranddbtests need Postgres. Only./notify/was tested.Do not merge before CI is green on the head SHA.