fix(group-file): correct GroupFileExtra wire shape — server was rejecting with result=79
Two off-by-one bugs in the group-file chat-post element that combined to make the QQ-NT server reject every group file send with result=79 (visible as "group file uploaded but chat post failed" in the logs): 1. Inner GroupFileInfo fields were shifted one tag left: - fileSha was field 5, should be field 6 - extInfo was field 6, should be field 7 - fileMd5 was field 7, should be field 8 Field 5 is actually a uint32 placeholder (`field5` in both NapCat and acidify). With the bug, our fileSha bytes were landing where the server expected a varint and the rest of the message got skipped as garbage. 2. Outer GroupFileExtra was missing the magic field1=6 + fileName slots that NapCat's encoder writes (`packet/message/element.ts:589`). Acidify's schema also models them as required even though it serialises with defaults. The current server build rejects sends without these slots populated. Cross-referenced: - NapCat `GroupFileExtraInfo` (component.ts:146-155) — matches our new field numbers exactly - acidify `GroupFileExtra.Inner.Info` (proto/message/extra/GroupFileExtra.kt) — same field numbers; their schema uses generic `field5`/`field7` names but the wire layout is identical Changes: - Proton + legacy schemas: shift inner fields, add outer field1/ fileName/display - `makeGroupFileElem`: write field1=6 + fileName on the outer wrapper - Regression test asserts each inner tag lands at 50/58/66 (not the old 42/50/58) and verifies the new outer field1 + fileName bytes are present
This commit is contained in:
4 files changed
+100
-7
No files matched your search
@@ -92,3 +92,57 @@ describe('element-builder / commonElem.businessType per scene', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('element-builder / group file element wire shape', () => {
|
||||
// Regression for the same `result=79` class: the GroupFileExtra outer
|
||||
// wrapper was missing the magic `field1=6` + `fileName` slots and the
|
||||
// inner GroupFileInfo had fileSha/extInfoString/fileMd5 shifted one
|
||||
// tag to the left (5/6/7 instead of the correct 6/7/8). Both
|
||||
// mistakes made the current QQ-NT server reject the chat post. This
|
||||
// test decodes the element back through the proton-generated codec
|
||||
// and asserts each field lands at the right tag.
|
||||
it('encodes outer field1=6 + fileName, and inner fields at tags 6/7/8', async () => {
|
||||
const [elem] = await buildSendElems(
|
||||
[{
|
||||
type: 'file',
|
||||
fileId: 'fid-abc',
|
||||
fileName: 'doc.txt',
|
||||
fileSize: 123,
|
||||
md5Hex: 'aabbccddeeff00112233445566778899',
|
||||
sha1Hex: '0102030405060708090a0b0c0d0e0f1011121314',
|
||||
} as any],
|
||||
{ bridge: fakeBridge, groupId: 12345 },
|
||||
);
|
||||
const transElem = (elem as any).transElem as { elemType: number; elemValue: Uint8Array };
|
||||
expect(transElem.elemType).toBe(24);
|
||||
// 0x01 prefix + BE16 length + payload
|
||||
expect(transElem.elemValue[0]).toBe(0x01);
|
||||
const len = (transElem.elemValue[1] << 8) | transElem.elemValue[2];
|
||||
const payload = transElem.elemValue.subarray(3, 3 + len);
|
||||
|
||||
// Hand-walk the wire bytes to verify each tag lands where the
|
||||
// server expects. Each varint tag = (field << 3) | wire_type:
|
||||
// outer field1=6 → tag 8 (wire 0 / varint), value 6
|
||||
// outer fileName → tag 18 (wire 2 / length-delimited), 'doc.txt'
|
||||
// outer inner → tag 58 (field 7 wire 2)
|
||||
// inner.info → tag 18 (field 2 wire 2)
|
||||
// info.busId → tag 8 (field 1 wire 0), value 102
|
||||
// info.fileId → tag 18 (field 2 wire 2)
|
||||
// info.fileSize → tag 24 (field 3 wire 0), value 123
|
||||
// info.fileName → tag 34 (field 4 wire 2)
|
||||
// info.fileSha → tag 50 (field 6 wire 2) ← was 42 (field 5)
|
||||
// info.extInfoString → tag 58 (field 7 wire 2) ← was 50 (field 6)
|
||||
// info.fileMd5 → tag 66 (field 8 wire 2) ← was 58 (field 7)
|
||||
const tagAt = (i: number) => payload[i];
|
||||
expect(tagAt(0)).toBe(8); // outer field1 tag — regression: missing entirely before
|
||||
expect(payload[1]).toBe(6); // value of field1 (NapCat hardcodes 6)
|
||||
expect(tagAt(2)).toBe(18); // outer fileName tag — regression: missing
|
||||
// Locate the inner GroupFileExtraInfo by scanning for tag 50 (was 42
|
||||
// in the bug). A naive scan for `0x32` is enough because no string
|
||||
// field happens to contain that byte in this test fixture.
|
||||
expect(payload.includes(50)).toBe(true); // fileSha at tag 50 (field 6)
|
||||
expect(payload.includes(58)).toBe(true); // extInfoString at tag 58 (field 7)
|
||||
expect(payload.includes(66)).toBe(true); // fileMd5 at tag 66 (field 8)
|
||||
expect(payload.includes(42)).toBe(false); // sanity: nothing at the old (wrong) tag for fileSha
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user