Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
787 stars 142 forks source link

[Bug]: Using a Development config file the entities are not merged #2233

Open frekvent-szabolcs opened 1 month ago

frekvent-szabolcs commented 1 month ago

What happened?

I have two configuration files:

dab-config.Development.json
dab-config.json

In the dab-config.json I defined the entities and in the dab-config.Development.json file I defined the database connection string and set the authentication to

    "runtime": {
        "host": {
            "authentication": {
                "provider": "Simulator"
            },
            "mode": "development"
        }
    },

If I do not define the entities object in the development file. I get an error during startup:

**2024-05-23 10:29:58 dab-test-dab-1  | Starting the runtime engine...
2024-05-23 10:29:58 dab-test-dab-1  | Loading config file from dab-config.Development.json.
2024-05-23 10:29:58 dab-test-dab-1  | Unable to launch the runtime due to: System.NullReferenceException: Object reference not set to an instance of an object.
2024-05-23 10:29:58 dab-test-dab-1  |    at Azure.DataApiBuilder.Config.ObjectModel.RuntimeConfig..ctor(String Schema, DataSource DataSource, RuntimeEntities Entities, RuntimeOptions Runtime, DataSourceFiles DataSourceFiles) in /_/src/Config/ObjectModel/RuntimeConfig.cs:line 181
2024-05-23 10:29:58 dab-test-dab-1  |    at .ctor(Object[] )
2024-05-23 10:29:58 dab-test-dab-1  |    at System.Text.Json.Serialization.Converters.LargeObjectWithParameterizedConstructorConverter`1.CreateObject(ReadStackFrame& frame)
2024-05-23 10:29:58 dab-test-dab-1  |    at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
2024-05-23 10:29:58 dab-test-dab-1  |    at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
2024-05-23 10:29:58 dab-test-dab-1  |    at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
2024-05-23 10:29:58 dab-test-dab-1  |    at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
2024-05-23 10:29:58 dab-test-dab-1  |    at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
2024-05-23 10:29:58 dab-test-dab-1  |    at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
2024-05-23 10:29:58 dab-test-dab-1  |    at Azure.DataApiBuilder.Config.RuntimeConfigLoader.TryParseConfig(String json, RuntimeConfig& config, ILogger logger, String connectionString, Boolean replaceEnvVar, String dataSourceName, Dictionary`2 datasourceNameToConnectionString, EnvironmentVariableReplacementFailureMode replacementFailureMode) in /_/src/Config/RuntimeConfigLoader.cs:line 67
2024-05-23 10:29:58 dab-test-dab-1  |    at Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader.TryLoadConfig(String path, RuntimeConfig& config, Boolean replaceEnvVar, String dataSourceName) in /_/src/Config/FileSystemRuntimeConfigLoader.cs:line 108
2024-05-23 10:29:58 dab-test-dab-1  |    at Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader.TryLoadKnownConfig(RuntimeConfig& config, Boolean replaceEnvVar, String dataSourceName) in /_/src/Config/FileSystemRuntimeConfigLoader.cs:line 145
2024-05-23 10:29:58 dab-test-dab-1  |    at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigProvider.TryGetConfig(RuntimeConfig& runtimeConfig) in /_/src/Core/Configurations/RuntimeConfigProvider.cs:line 125
2024-05-23 10:29:58 dab-test-dab-1  |    at Azure.DataApiBuilder.Service.Startup.ConfigureServices(IServiceCollection services) in /_/src/Service/Startup.cs:line 92
2024-05-23 10:29:58 dab-test-dab-1  |    at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
2024-05-23 10:29:58 dab-test-dab-1  |    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2024-05-23 10:29:58 dab-test-dab-1  |    at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
2024-05-23 10:29:58 dab-test-dab-1  |    at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
2024-05-23 10:29:58 dab-test-dab-1  |    at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
2024-05-23 10:29:58 dab-test-dab-1  |    at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
2024-05-23 10:29:58 dab-test-dab-1  |    at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance)
2024-05-23 10:29:58 dab-test-dab-1  |    at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass14_0`1.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
2024-05-23 10:29:58 dab-test-dab-1  |    at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
2024-05-23 10:29:58 dab-test-dab-1  |    at Microsoft.Extensions.Hosting.HostBuilder.Build()
2024-05-23 10:29:58 dab-test-dab-1  |    at Azure.DataApiBuilder.Service.Program.StartEngine(String[] args) in /_/src/Service/Program.cs:line 39**

If I define the entities as "entities": {}, DAB can start, but the graphql schema will not be available. image

2024-05-23 10:32:43 dab-test-dab-1  | fail: Microsoft.AspNetCore.Server.Kestrel[13]
2024-05-23 10:32:43 dab-test-dab-1  |       Connection id "0HN3R0BA6GA1J", Request id "0HN3R0BA6GA1J:00000003": An unhandled exception was thrown by the application.
2024-05-23 10:32:43 dab-test-dab-1  |       HotChocolate.SchemaException: For more details look at the `Errors` property.
2024-05-23 10:32:43 dab-test-dab-1  |       
2024-05-23 10:32:43 dab-test-dab-1  |       1. The object type `Query` has to at least define one field in order to be valid. (HotChocolate.Types.ObjectType)
2024-05-23 10:32:43 dab-test-dab-1  |       
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.Configuration.TypeInitializer.Initialize()
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.SchemaBuilder.Setup.InitializeTypes(SchemaBuilder builder, IDescriptorContext context, IReadOnlyList`1 types, LazySchema lazySchema)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.SchemaBuilder.Setup.Create(SchemaBuilder builder, LazySchema lazySchema, IDescriptorContext context)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.SchemaBuilder.Create(IDescriptorContext context)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.SchemaBuilder.HotChocolate.ISchemaBuilder.Create(IDescriptorContext context)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.Execution.RequestExecutorResolver.CreateSchemaAsync(NameString schemaName, RequestExecutorSetup options, RequestExecutorOptions executorOptions, IServiceProvider serviceProvider, TypeModuleChangeMonitor typeModuleChangeMonitor, CancellationToken cancellationToken)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.Execution.RequestExecutorResolver.CreateSchemaServicesAsync(NameString schemaName, RequestExecutorSetup options, CancellationToken cancellationToken)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorNoLockAsync(NameString schemaName, CancellationToken cancellationToken)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorAsync(NameString schemaName, CancellationToken cancellationToken)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.Execution.RequestExecutorProxy.GetRequestExecutorAsync(CancellationToken cancellationToken)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.AspNetCore.HttpPostMiddlewareBase.HandleRequestAsync(HttpContext context, AllowedContentType contentType)
2024-05-23 10:32:43 dab-test-dab-1  |          at HotChocolate.AspNetCore.HttpPostMiddlewareBase.InvokeAsync(HttpContext context)
2024-05-23 10:32:43 dab-test-dab-1  |          at Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.<>c__DisplayClass12_0.<<UseCancellation>b__1>d.MoveNext()
2024-05-23 10:32:43 dab-test-dab-1  |       --- End of stack trace from previous location ---
2024-05-23 10:32:43 dab-test-dab-1  |          at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
2024-05-23 10:32:43 dab-test-dab-1  |          at Azure.DataApiBuilder.Core.Authorization.ClientRoleHeaderAuthorizationMiddleware.Invoke(HttpContext httpContext) in /_/src/Core/Authorization/ClientRoleHeaderAuthorizationMiddleware.cs:line 35
2024-05-23 10:32:43 dab-test-dab-1  |          at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
2024-05-23 10:32:43 dab-test-dab-1  |          at Azure.DataApiBuilder.Core.AuthenticationHelpers.ClientRoleHeaderAuthenticationMiddleware.InvokeAsync(HttpContext httpContext) in /_/src/Core/AuthenticationHelpers/ClientRoleHeaderAuthenticationMiddleware.cs:line 139
2024-05-23 10:32:43 dab-test-dab-1  |          at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
2024-05-23 10:32:43 dab-test-dab-1  |          at Azure.DataApiBuilder.Service.Startup.<>c__DisplayClass15_0.<<Configure>b__3>d.MoveNext() in /_/src/Service/Startup.cs:line 345
2024-05-23 10:32:43 dab-test-dab-1  |       --- End of stack trace from previous location ---
2024-05-23 10:32:43 dab-test-dab-1  |          at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
2024-05-23 10:32:43 dab-test-dab-1  |          at Azure.DataApiBuilder.Core.Services.PathRewriteMiddleware.InvokeAsync(HttpContext httpContext) in /_/src/Core/Services/PathRewriteMiddleware.cs:line 89
2024-05-23 10:32:43 dab-test-dab-1  |          at Azure.DataApiBuilder.Core.Services.CorrelationIdMiddleware.Invoke(HttpContext httpContext) in /_/src/Core/Services/CorrelationIdMiddleware.cs:line 53
2024-05-23 10:32:43 dab-test-dab-1  |          at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

If I define a single entity inside the development config file, only that specific entity will be available for queries. This way, I have to define every entity in both the development and the "live" configuration.

Version

1.1.7

What database are you using?

Azure SQL

What hosting model are you using?

Local (including CLI), Custom Docker host

Which API approach are you accessing DAB through?

REST, GraphQL

Relevant log output

No response

Code of Conduct

tgermain-impirica commented 1 day ago

Hi team,

This seems like a MAJOR breaking change for anyone using DAB in development. This issue is a month old. The documentation clearly states that configuration works like appSettings, and that a base configuration can be combined with an environment specific configuration. This is completely broken.

Any update on when a fix for this breaking change will be resolved?