← Back to Case Library

QKeyDB stringifier silently corrupts arrays of objects on re-parse

DomainQKEYDB ImpactCritical
Error Signature
Case/collection remedy field becomes null after stringify-then-reparse round trip, with fields leaked onto an unrelated sibling object

QKeyDB's formatQKeyValue function joined array items containing nested objects inline as [{...}, {...}], putting an opening brace directly against the array's opening bracket with no line break. The format spec never allows braces and brackets to touch across a nesting boundary - the parser correctly rejects this shape, and in some field positions the malformed text did not even throw: it silently misattributed the object's fields to the wrong parent, producing field: null with the object's keys leaked onto a sibling object one level up.

Root Cause

The array-formatting branch of formatQKeyValue used items.join(', ') inside a single-line [${...}] wrapper regardless of whether items were nested objects/arrays or plain scalars, instead of switching to multi-line output when any item is a nested object or array.

Solution Steps

  1. In formatQKeyValue's array-formatting branch, detect when any array item is a nested object or array (hasNestedItems check).
  2. When true, emit each item on its own indented line inside [\n ... \n], instead of joining items with ', ' inside a single-line [...] wrapper. Plain scalar arrays keep the compact single-line form.
  3. Run Qkeydb's dedicated qkeyConverter test files to confirm no regression.

Validation

[object Object]

Rollback

[object Object]

Ecosystem: qkeydb

License: CC-BY-4.0

Last updated: Jul 6, 2026

Case ID: f31551ae-7012-48f8-a08f-aa3ae3dff354