Your JSON is valid and your invoice is wrong
Описание и применение
При рефакторинге структуры JSON данные, ожидаемые шаблоном, меняются, но привязка шаблона остаётся прежней, что приводит к созданию счетов без имени клиента или с неверным именем. Решение – явно сопоставлять новые поля с шаблоном и проверять соответствие контракта.
Задача
A refactor changes the JSON payload shape, but the template binding remains unchanged, causing invoices to be generated without a customer name or with the wrong name.
Результат
By explicitly mapping new JSON fields to template placeholders and validating against a defined contract, invoices are prevented from being generated with missing or incorrect customer data.
Рабочий процесс
- 1. Refactor backend to use new JSON shape.
- 2. Detect schema mismatch between incoming data and template contract.
- 3. Create a mapping proposal (e.g.,
customer.legalName → client.name). - 4. Validate mapping with synthetic test cases covering normal, missing, and conflicting data.
- 5. Review and approve mapping, saving it with a
mappingIdtied to the template revision. - 6. Render invoice using the approved mapping, receiving a 422 SCHEMA_DRIFT error if mismatched.
- 7. Verify rendered PDF contains correct customer information.
Доказательства
Both are valid JSON. Both contain the same company name.
If the integration quietly converts a missing value into an empty string, the PDF may still render.
A structural validator can check that a string exists at a declared path. It cannot infer which business entity you intended to bill just because two field names look related.
In Bitavu, a detected schema mismatch is reported as 422 SCHEMA_DRIFT.
- Дата записи: 2026-11-03T20:13:50.903Z