Skip to content

[Bug]: Schema validation fail in dab config throws exception #3268

@JerryNixon

Description

@JerryNixon

What?

When running dab validate and there is neither autoentities nor entities (or any other reason the JSON Schema validation would fail) it should report this as a validation error, not throw an exception.

Current output

C:\Temp\dab-todo-test>dab validate
Information: Microsoft.DataApiBuilder 2.0.0
Information: Config not provided. Trying to get default config based on DAB_ENVIRONMENT...
Information: Environment variable DAB_ENVIRONMENT is Development
Information: Validating config file: dab-config.json
Deserialization of the configuration file failed during a post-processing step.
Message:
 Configuration file should contain either at least the entities or autoentities property
Stack Trace:
    at Azure.DataApiBuilder.Config.ObjectModel.RuntimeConfig..ctor(String Schema, DataSource DataSource, RuntimeEntities Entities, RuntimeAutoentities Autoentities, RuntimeOptions Runtime, DataSourceFiles DataSourceFiles, AzureKeyVaultOptions AzureKeyVault) in /_/src/Config/ObjectModel/RuntimeConfig.cs:line 317
   at .ctor(Object[])
   at System.Text.Json.Serialization.Converters.LargeObjectWithParameterizedConstructorConverter`1.CreateObject(ReadStackFrame& frame)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at Azure.DataApiBuilder.Config.RuntimeConfigLoader.TryParseConfig(String json, RuntimeConfig& config, DeserializationVariableReplacementSettings replacementSettings, ILogger logger, String connectionString) in /_/src/Config/RuntimeConfigLoader.cs:line 215    
Information: Failed to parse the config file
Error: Config is invalid. Check above logs for details.

Desired output

C:\Temp\dab-todo-test>dab validate
Information: Microsoft.DataApiBuilder 2.0.0
Information: Validating config file: dab-config.json
Error: Configuration file should contain either at least the entities or autoentities property
Information: Config is invalid. 
Image

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions