Skip to content

Cherry-pick: LogLevel & Autoentity bugs fixes#3457

Merged
Aniruddh25 merged 4 commits intorelease/2.0from
dev/rubencerna/log-level-cherry-pick
Apr 23, 2026
Merged

Cherry-pick: LogLevel & Autoentity bugs fixes#3457
Aniruddh25 merged 4 commits intorelease/2.0from
dev/rubencerna/log-level-cherry-pick

Conversation

@RubenCerna2079
Copy link
Copy Markdown
Contributor

@RubenCerna2079 RubenCerna2079 commented Apr 22, 2026

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

RubenCerna2079 and others added 4 commits April 22, 2026 13:14
## 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)
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 start from implicitly overriding config-defined log levels unless --LogLevel is 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-tooltemplate.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.

Comment thread src/Cli.Tests/EndToEndTests.cs
Copy link
Copy Markdown
Contributor

@souvikghosh04 souvikghosh04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved the 4 mentioned cherry picks

@souvikghosh04 souvikghosh04 moved this from Todo to Review In Progress in Data API builder Apr 23, 2026
@Aniruddh25 Aniruddh25 assigned Aniruddh25 and unassigned anushakolan Apr 23, 2026
@Aniruddh25 Aniruddh25 merged commit 3bc42d2 into release/2.0 Apr 23, 2026
18 checks passed
@Aniruddh25 Aniruddh25 deleted the dev/rubencerna/log-level-cherry-pick branch April 23, 2026 22:55
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Data API builder Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants