Azure / iot-plugandplay-models-tools

Tools to manage the device-models repo
MIT License
13 stars 18 forks source link

Validate does not support inline extends #100

Closed rido-min closed 3 years ago

rido-min commented 3 years ago

https://github.com/iotmodels/iot-plugandplay-models-test/pull/11/checks?check_run_id=1267022517#step:6:33

Validating this model https://github.com/iotmodels/iot-plugandplay-models-test/blob/rido/central/dtmi/com/example/base-1.json#L14

I got this exception.

Unhandled exception: System.InvalidOperationException: The requested operation requires an element of type 'String', but the target element has type 'Array'.
   at System.Text.Json.JsonDocument.GetString(Int32 index, JsonTokenType expectedType)
   at System.Text.Json.JsonElement.GetString()
   at Azure.DigitalTwins.Validator.Validations.ValidateContext(String fileText, String fileName) in /home/runner/work/iot-plugandplay-models-tools/iot-plugandplay-models-tools/resolvers/dotnet/Azure.DigitalTwins.Validator/ValidateContext.cs:line 27
   at Azure.DigitalTwins.Validator.Validations.ValidateContext(FileInfo fileInfo) in /home/runner/work/iot-plugandplay-models-tools/iot-plugandplay-models-tools/resolvers/dotnet/Azure.DigitalTwins.Validator/ValidateContext.cs:line 17
   at Azure.DigitalTwins.Resolver.CLI.Program.<>c.<<BuildValidateCommand>b__9_0>d.MoveNext() in /home/runner/work/iot-plugandplay-models-tools/iot-plugandplay-models-tools/resolvers/dotnet/Azure.DigitalTwins.Resolver.CLI/Program.cs:line 225
digimaun commented 3 years ago

This is an issue caused by one of the additional validations introduced with --strict. It is the @context check validation, which in current state assumes a value type of string but in the input model its an array.

I suspect its not an issue in prod since --strict is not being used yet. I have validated that in my fork here. Rather than remediate the context validation, I think we should consider just dropping that validation altogether and let context correctness be handled by the parser.

rido-min commented 3 years ago

Agree with letting the parser handle the context validation.

This issue is to ensure we allow inline extends