Closed zepumph closed 1 year ago
Patch to reproduce a silent failure of validation:
@samreid and I found 2 issues.
The first is that we were not correctly iterating up to the base case (supertype with no more supertype) correctly. This seems to have been a problem ever since we created stateSchema and merged it onto master.
The second issue is a hard failure in validating if the schema expects a "level" but the stateObject is undefined at that level.
This changes the API, let's cherry pick this into ph-scale!!
@samreid and I feel good about master. see https://github.com/phetsims/ph-scale/issues/279 for cherry picks in ph-scale.
Oops. @samreid please note the newly needed migration rules here, since schema validation was fixed in this issue. We should definitely cherry pick that in https://github.com/phetsims/ph-scale/issues/279
The above linked issues came out of CT results from this bug fix. Woo!! Both cases were obvious and easy oversights. I'm glad the assertion is working as expected. We may find more of these in the future when current validation:false phet-io sims turn on/test with validation.
@samreid and I greatly improved upon my crappy rules committed back in https://github.com/phetsims/tandem/issues/290#issuecomment-1404355949. We made a single, more general rule that applies to the stateObject serialization for the whole PhET-iO type, not just by each single phetioID. We feel much much better about the work-in-progress.
Note that AddStateElement
is currently a hack, and next time we run into it, we should outfit it to be more general, and similar to IOTypeStateAttributeDelete
.
There has been a regression since some StateSchema work in which validation that keeps the stateObject looking like the stateSchema is not working correctly. This was originally identified in https://github.com/phetsims/ph-scale-basics/issues/56#issuecomment-1400799512.