ankidroid / ankidroid/Anki-Android

Statistics and APKG import fail with Protobuf errors after reviewer creates large cookies

Đang mở
#21,632 2 bình luận 0 reaction 1 người được giao Được @AdwikaVishal nhận Xem trên GitHub
Needs Triage
Ngôn ngữ chính
Kotlin
Star
11.8k
Fork
2.9k
Merge trung bình
2 ngày 3 giờ
Pull request đã merge (30 ngày)
171

Mô tả

### Checked for duplicates?

- [x] This issue is not a duplicate

### Does it also happen in the desktop version?

- [ ] This bug does not occur in the latest version of Anki Desktop

### What are the steps to reproduce this bug?

I can reproduce this on a clean Android 16 / API 36 emulator with 4 KB pages, AnkiDroid 2.24.0, and Android System WebView 147.0.7727.137. The attached ZIP contains a one-card APKG with no media, its complete front template, and the script used to build it.

1. Import `ankidroid-loopback-cookie-reproducer.apkg`.
2. Open its only card once. It creates 24 local test cookies and reports 60,718 characters. It makes no network requests.
3. Open Statistics. It fails with `Error: 500: ProtoError { info: "failed to decode Protobuf message: invalid wire type value: 7" }`.
4. Select the same APKG again and press Import on the import-options screen. It fails with `500: Protocol message contained an invalid tag (zero).`

The card has a Clear test cookies button. After using it, Statistics loads normally again without reinstalling AnkiDroid. The test cookies also expire after one hour.

[ankidroid-loopback-cookie-reproducer.zip](https://github.com/user-attachments/files/31556916/ankidroid-loopback-cookie-reproducer.zip)

### Expected behaviour

Statistics should load, and importing the same valid APKG again should complete without a Protobuf decoding error.

### Debug info

```text
AnkiDroid Version = 2.24.0 (ebcf8e0e34921628b9b8a496c66ffd4adbb3705f)
Backend Version = 0.1.64-anki25.09.2 (25.09.2 3890e12c9e48c028c3f12aa58cb64bd9f8895e30)
Android Version = 16 (SDK 36)
ProductFlavor = full
Device Info = Google | google | emu64a | sdk_gphone64_arm64 | sdk_gphone64_arm64 | ranchu
WebView Info = [com.google.android.webview | 772713704]: Mozilla/5.0 (Linux; Android 16; sdk_gphone64_arm64 Build/BE2A.250530.026.F3; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/147.0.7727.137 Mobile Safari/537.36
ACRA UUID = 09950e2a-bb8b-4644-be60-eb643b26802a
FSRS = 5.1.0 (Enabled: false)
Crash Reports Enabled = true
```

### (Optional) Anything else you want to share?

I built the APKG from [`AnkiDroid/src/androidTest/assets/update1.apkg`](https://github.com/ankidroid/Anki-Android/blob/ebcf8e0e34921628b9b8a496c66ffd4adbb3705f/AnkiDroid/src/androidTest/assets/update1.apkg). The included script replaces only the card template, names, description, and note fields, then re-zips `collection.anki2` and `media`. APKG SHA-256: `562905cb853b23c93dc6bcbb6cc70318a643ef448388c37d1c909b07f17cf7ae`. ZIP SHA-256: `6e30e6a83e551b06f7c20d1e5d7507ffc5c03d3859467d3f0731738967b24d6a`.

I checked the exact APKG with Anki Desktop's bundled backend 25.09.2 (`3890e12c`) in a disposable collection. It imported as one note and one card, and both the 365-day and all-history `graphs` calls completed successfully.

Related: #21412. That report focused on the reviewer JavaScript API and was closed after treating a cookie header over 8 KiB as add-on misuse. This reproducer shows the same cookie jar also breaks AnkiDroid's built-in Statistics and APKG import. This is the self-contained new report requested after #21618 was closed.

### Research

- [x] I have checked the [manual](https://docs.ankidroid.org/) and the [FAQ](https://github.com/ankidroid/Anki-Android/wiki/FAQ) and could not find a solution to my issue
- [ ] (Optional) I have confirmed the issue is not resolved in the latest alpha release ([instructions](https://docs.ankidroid.org/manual.html#betaTesting))

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.