Produced apkg has missing did field in JSON

Hello, I am needing to load/save apkg files for my Rust project. Loading is fine, but using the information on Database Structure · ankidroid/Anki-Android Wiki · GitHub , anki won’t load my saved apkg. It complains about a missing “did” field in one of the JSON objects in the col table. However, I’ve printed out the JSON and all the objects seem to have a “did” field, as I manually inserted null in cases where it was missing from the input deck. The code is at GitHub - aftix/acp: Anki Card Parser

Update: I have fixed this particular problem, but when loading models I now get an error " {info: “1 field required”}"