Skip to content

finding: ?preview=draft self-inflicts an invalid diagnostic — the injected _draft key is validated, so the read carries _diagnostics.valid:false #7656

Description

@huangyiirene

Unconfirmed observation from the QA run — recorded for triage; the injection site was located but the fix (strip _draft before computing _diagnostics, or whitelist the read-decoration keys in the diagnostics validation) is the natural next step to confirm.

Symptom

Reading a metadata item with ?preview=draft returns a response whose own diagnostics call the item invalid because of a key the read itself injected.

  • Observed: the response carries _diagnostics.valid:false with "Unrecognized key(s) … _draft".
  • Expected:_diagnostics.valid:true for an otherwise-valid draft — the preview marker must not be validated against the item's strict schema.

Root cause (as located, unconfirmed)

The draft-preview read injects _draft:true onto the item and then validates the item with that key still present. In packages/metadata-protocol/src/protocol.ts the single-item draft read stamps (draftItem as any)._draft = true (around protocol.ts:4441, and the list overlay at :4261) and then decorates/validates it; the item schema is strict, so _draft is rejected by name. stripReadDecorations exists to remove exactly these stamped keys before a strict re-parse, but it is not applied on the path that computes _diagnostics for the draft read. Mechanism still present on origin/main.

Related but distinct: #6810 (closed) was the same class of defect for the indexed key at a different injection site — see the module header in packages/metadata-core/src/injected-system-columns.ts. This one is the _draft preview marker.

Reproduction

  1. Create a draft of a valid metadata item (e.g. an object).
  2. GET /api/v1/meta/<type>/<name>?preview=draft.
  3. Inspect _diagnostics in the response → valid:false, "Unrecognized key(s) … _draft".

Source

Extracted from the QA run #7627 (framework 92f26f7, console 6314e87f).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions