Cherry-pick: LogLevel & Autoentity bugs fixes#3457
Merged
Aniruddh25 merged 4 commits intorelease/2.0from Apr 23, 2026
Merged
Conversation
## Why make this change? - #3068 - #3304 Currently the inclusion of the autoentities feature causes hot-reload to fail when it should succeed. ## What is this change? Now the autoentities are updated when the hot-reload succeeds by ensuring that the generated entities from the autoentities property are removed if the initialization to connect to a database is done specifically for validation purposes. Since currently, hot-reload first validates before running the actual initialization, which would cause the autoentities to fail by trying to add the generated entities that already existed. - `Entity.cs` & `MsSqlMetadataProvider.cs`: Added new parameter that shows if an entity was generated through the autoentities property or just a regular entity. - `RuntimeConfigProvider.cs`, `RuntimeConfig.cs` & `SqlMetadataProvider.cs`: Added function that removes the generated autoentities from the RuntimeConfig object and also removes the relation between the autoentity with the data source. - `ConfigurationHotReloadTests.cs`: Added test to ensure autoentities works with hot-reload. - `dab.draft.schema.json`: Fixed small bug that caused validation to fail when using the `autoentities.mcp.dml-tools`. If the validation fails it also causes hot-reload to fail. ## How was this tested? - [ ] Integration Tests - [X] Unit Tests --------- Co-authored-by: aaronburtle <93220300+aaronburtle@users.noreply.github.com>
## Why make this change? - Closes #3263 - Closes #3264 - Closes #3265 Currently some of the logs for autoentities are not completely clear or they are too noisy. Which is why the messages need to be changed. ## What is this change? This changes the log messages so they are more clear by adding `' '` to the definition names from the autoentities, and stating that they are definition names beforehand. We also change the name from `Autoentities` to `autoentities` in the logs so that they are all consistent. Lastly we also change some of the logs from `Information` to `Debug`. ## How was this tested? Tested locally since all the changes are related to the messages written in the logs.
## Why make this change? - #3375 - The CLI and the schema have a mismatch in the `autoentities.<def-name>.template.mcp.dml-tools`, need to ensure that they are the same. - #3335 - Using `dab validate` produces the wrong output message. ## What is this change? For issue #3375: - We changed the `AutoConfigOption.cs` file so that it uses the proper name and changed the name of the variable to also match the schema in the `ConfigGenerator.cs`. For issue #3335: - We changed the log message in `MsSqlMetadataProvider.cs` so that it is easier for the user to understand the error. ## How was this tested? - [ ] Integration Tests - [ ] Unit Tests - [x] Local Testing The issues were related to mismatches or to the output of log messages that can only be tested locally. ## Sample Request(s) dab auto-config <def-name> --template.mcp.dml-tools true/false dab validate --config test.json --------- Co-authored-by: Souvik Ghosh <souvikofficial04@gmail.com> Co-authored-by: Aniruddh Munde <anmunde@microsoft.com>
## Why make this change? - Closes issue #3258 Whenever we use the `dab start` command the CLI overrides the minimum LogLevel from the configuration file. This is acceptable only if we use the `--LogLevel` flag. If we do not use that flag, the LogLevel for each namespace should be decided by the configuration file. ## What is this change? This change moves the `args.Add` methods inside the `ConfigGenerator.cs` so that they are only applied when we use the `--LogLevel` flag. Having these arguments causes DAB to not allow any changes to the LogLevel in the loggers, since those arguments were always being added, DAB always assumed the CLI was overriding the LogLevel when it was not expected as it would use the `--LogLevel` flag to determine if it was an `IsLogLevelOverridenByCli` scenario. ## How was this tested? - [ ] Integration Tests - [x] Unit Tests - [x] Manual Tests Tested with different configurations of the namespaces in the `log-level` property inside the config file. Note: ALL these manual tests were tested by running the CLI as well as running DAB through Visual Studio. Config file includes: ``` "log-level": { "Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider": "Information", "Azure.DataApiBuilder.Core": "Debug", "Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader": "Error", "default": "Warning" } ``` Expected results: - All the logs from `Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider` will provide logs from log level information and above. - All logs from `Azure.DataApiBuilder.Core` and its sub-namespaces that are not from `ISqlMetadataProvider` will provide logs from log level debug and above. - All logs from `Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader` will provide logs from log level error and above. - Everything else will provide logs from log level warning and above, including CLI. Config file includes: ``` "log-level": { "Azure.DataApiBuilder.Core": "Information", "Azure.DataApiBuilder.Config": "Debug", } ``` Expected results: - All logs from `Azure.DataApiBuilder.Core` and its sub-namespaces will provide logs from log level information and above. - All logs from `Azure.DataApiBuilder.Config` and its sub-namespaces will provide logs from log level debug and above. - Everything else will provide logs from log level debug and above with `host.mode = development`, including CLI. Config file includes: ``` "log-level": { "Default: none } ``` Expected results: - No logs will be printed, including CLI. ## Sample Request(s) dab start --LogLevel information dab start (With config file default value debug)
Contributor
There was a problem hiding this comment.
Pull request overview
Cherry-picks upstream fixes for DAB 2.0 RC issues around (1) CLI log-level override behavior and (2) autoentities generation/hot-reload validation behavior, plus related schema/CLI alignment updates.
Changes:
- Prevent
dab startfrom implicitly overriding config-defined log levels unless--LogLevelis explicitly provided. - Mark autoentity-generated entities (
Entity.IsAutoentity) and remove them after validate-only initialization to avoid hot-reload duplicate entity conflicts. - Align CLI option naming and JSON schema behavior for
autoentities.*.template.mcp.dml-tools, and update/add tests accordingly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Service.Tests/UnitTests/SqlMetadataProviderUnitTests.cs | Updates unit test to match QueryAutoentitiesAsync signature change. |
| src/Service.Tests/ModuleInitializer.cs | Ignores new Entity.IsAutoentity member in snapshot verification. |
| src/Service.Tests/Configuration/HotReload/ConfigurationHotReloadTests.cs | Adds hot-reload coverage for autoentities and extends generated config with autoentities. |
| src/Service.Tests/Configuration/ConfigurationTests.cs | Updates expected error message for autoentity/entity name conflicts. |
| src/Core/Services/MetadataProviders/SqlMetadataProvider.cs | Removes generated autoentities from config after validate-only initialization. |
| src/Core/Services/MetadataProviders/MsSqlMetadataProvider.cs | Improves autoentities logging/messages, flags generated entities as IsAutoentity, and extends query method signature. |
| src/Core/Configurations/RuntimeConfigProvider.cs | Adds helper to remove generated autoentity entities from runtime config. |
| src/Config/ObjectModel/RuntimeConfig.cs | Adds entity→datasource mapping removal for generated autoentities; refines autoentity-not-found message. |
| src/Config/ObjectModel/Entity.cs | Introduces IsAutoentity marker property (non-serialized). |
| src/Cli/ConfigGenerator.cs | Stops adding --LogLevel args unless --LogLevel flag is provided; renames CLI template option handling to dml-tools. |
| src/Cli/Commands/AutoConfigOptions.cs | Renames CLI option template.mcp.dml-tool → template.mcp.dml-tools. |
| src/Cli.Tests/ModuleInitializer.cs | Ignores new Entity.IsAutoentity member in snapshot verification. |
| src/Cli.Tests/EndToEndTests.cs | Adds test for Startup.IsLogLevelOverriddenByCli behavior (but currently has a test design issue). |
| src/Cli.Tests/AutoConfigTests.cs | Updates tests to use renamed CLI option property templateMcpDmlTools. |
| schemas/dab.draft.schema.json | Adjusts autoentities template mcp schema to accept boolean shorthand or object form. |
souvikghosh04
approved these changes
Apr 23, 2026
Contributor
souvikghosh04
left a comment
There was a problem hiding this comment.
Approved the 4 mentioned cherry picks
Aniruddh25
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
This change cherry-picks the PRs that fix the LogLevel & Autoentity bugs that appear in the release candidate for DAB 2.0.
What is this change?
Cherry-picked PRs:
How was this tested?
Existing tests in cherry-pick cover new changes.
Sample Request(s)
N/A