Skip to content

Distinguish absent vs empty required field in YAML gate#73

Merged
VPDPersonal merged 1 commit into
feature/serialize-reference-dropdownfrom
fix/sr-required-gate-absent-key
Jun 23, 2026
Merged

Distinguish absent vs empty required field in YAML gate#73
VPDPersonal merged 1 commit into
feature/serialize-reference-dropdownfrom
fix/sr-required-gate-absent-key

Conversation

@VPDPersonal

Copy link
Copy Markdown
Owner

Summary

  • The required-field gate's pure-YAML scene scan (SerializeReferenceYamlEditor.FindUnsetRequiredFields) no longer treats a totally absent top-level field key as a violation. Unity omits a serialized field from YAML when the object was last saved before the [TypeSelector(Required = true)] field was added (and for stripped / nested-prefab docs), so the old behavior produced a CI false-positive (-srGateRequired at Fail severity exited 1 on a project that is valid once reopened).
  • Both field helpers now return a tri-state FieldState (Absent / PresentSet / PresentUnset); only PresentUnset is reported. An absent key is left for a reserialize, which is exactly how the object-load path (which can read defaulted properties) already behaves.
  • Added an absent-keys YAML fixture and a regression test asserting no violations are reported when the required keys are missing from the document.

Notes for review

  • The object-load path (SerializeReferenceRequiredGate.IsViolation / CollectRequiredViolations) is intentionally unchanged: it walks live SerializedObject properties, where every declared field is present (Unity reserializes on load), so it has no absent-key false-positive. The asymmetry is the point — the YAML scan can't reserialize, so it must not flag what it can't see.
  • The two helper methods keep their Is…Unset names despite now returning a tri-state enum; they have no other callers, so renaming would be churn outside this finding's scope.

Linked issues

Refs #49 - addresses review finding #49 (comment)

@VPDPersonal VPDPersonal added type: fix Bug fix status: needs-review Ready for review area: editor Editor-only code labels Jun 21, 2026
@VPDPersonal VPDPersonal merged commit b82a2d7 into feature/serialize-reference-dropdown Jun 23, 2026
1 check passed
@VPDPersonal VPDPersonal deleted the fix/sr-required-gate-absent-key branch June 23, 2026 14:04
@github-actions github-actions Bot removed the status: needs-review Ready for review label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: editor Editor-only code type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant