#2483·capnproto

Enforcing message conformance with schema

Author: Milek7Created Dec 24, 2025Updated Jan 19, 2026

I have usecase that might be somewhat unusual, as I'm storing Capnp messages in persistent database. These might contain references to other entries as Int64 fields with appropiate schema annotations. Server enforces referential integrity by iterating over fields with DynamicStruct::Reader and verifies each field that has annotation.

There's a potential issue when server receives message containing fields not known in schema that server was compiled with, as it won't be able to verify these fields and might store object with broken references into database. I need to either reject such messages or strip unknown fields. Is there a nice way to do it, or I would need to manually iterate through each field and rebuild the message with DynamicStruct::Builder?