Skip to content

Fix: child-config autoentities fails validation with "No entities found" when using data-source-files - #3723

Open
RubenCerna2079 with Copilot wants to merge 19 commits into
mainfrom
copilot/fix-autoentities-in-child-configs
Open

RubenCerna2079 with Copilot wants to merge 19 commits into
mainfrom
copilot/fix-autoentities-in-child-configs

Conversation

Copilot AI commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Why make this change?

What is this change?

  • Root cause: MsSqlMetadataProvider.GenerateAutoentitiesIntoEntities stores autoentity resolution counts only on the root (merged) RuntimeConfig.AutoentityResolutionCounts. But ValidateEntityPresence checks the child config's own AutoentityResolutionCounts, which is never populated — so the resolved entity count is always 0 for child configs.

  • Fix (RuntimeConfigValidator.ValidateRootConfig): Before validating each child config, copy any missing resolution counts from the root config into the child config. This is a no-op when child counts are already populated (e.g. in unit tests that pre-populate them directly).

foreach (KeyValuePair<string, Autoentity> ae in childConfig.Autoentities)
{
    if (!childConfig.AutoentityResolutionCounts.ContainsKey(ae.Key)
        && runtimeConfig.AutoentityResolutionCounts.TryGetValue(ae.Key, out int count))
    {
        childConfig.AutoentityResolutionCounts[ae.Key] = count;
    }
}

How was this tested?

  • Integration Tests
  • Unit Tests
    • TestChildWithDataSourceAndAutoentitiesResolvingEntitiesIsValid: child config with only autoentities resolving >0 entities (counts stored on root only) passes validation — direct regression test for the bug.
    • TestRootAndChildBothWithAutoentitiesResolvingEntitiesIsValid: both root and child have autoentities, all counts on root, both pass validation.

Sample Request(s)

// dab-config.child.json — previously caused "No entities found" during `dab validate`
{
  "data-source": { "database-type": "mssql", "connection-string": "@env('CONN_B')" },
  "autoentities": {
    "def-b": {
      "patterns": { "name": "b_{object}", "include": [ "dbo.TableTwo" ] },
      "permissions": [ { "role": "anonymous", "actions": [ { "action": "read" } ] } ]
    }
  }
}
dab validate -c dab-config.json  # now passes when child uses autoentities

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

…alidation

When using `data-source-files`, the metadata provider stores autoentity
resolution counts only on the root (merged) config. ValidateRootConfig
now copies those counts to each child config before per-child validation,
so child configs with only autoentities correctly pass the entity-presence
check instead of failing with "No entities found".

Adds two regression tests:
- TestChildWithDataSourceAndAutoentitiesResolvingEntitiesIsValid
- TestRootAndChildBothWithAutoentitiesResolvingEntitiesIsValid
Copilot AI changed the title [WIP] Fix autoentities recognition in child configuration files Fix: child-config autoentities fails validation with "No entities found" when using data-source-files Jul 14, 2026
Copilot AI requested a review from RubenCerna2079 July 14, 2026 21:22
@RubenCerna2079

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a validation gap in DAB’s multi-file configuration flow: when a child config (loaded via data-source-files) uses autoentities without explicit entities, validation could incorrectly fail with “No entities found” because autoentity resolution counts were only tracked on the merged/root config.

Changes:

  • Copy missing AutoentityResolutionCounts entries from the merged/root config into each child config prior to per-child validation.
  • Add CLI unit tests covering child-only autoentities resolving >0 entities, and combined root+child autoentities with counts stored only on the root.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Core/Configurations/RuntimeConfigValidator.cs Ensures child-config validation can see autoentity resolution counts produced during metadata initialization on the merged/root config.
src/Cli.Tests/ValidateConfigTests.cs Adds regression coverage for child configs using autoentities under data-source-files where counts exist only on the root config.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).

@RubenCerna2079

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).

…ities-in-child-configs' into copilot/fix-autoentities-in-child-configs
@RubenCerna2079

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).

@RubenCerna2079

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[Bug]: autoentities in a child configuration file (referenced via data-source-files) is not recognized — validation fails with "No entities found"

7 participants