Update config validation logic for entities#3306
Merged
aaronburtle merged 34 commits intomainfrom May 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a CLI validation-time warning to help users detect “valid” configs that define no entities (and have no autoentities / multi-config datasource files), aligning dab validate behavior with Issue #3267.
Changes:
- Adds a
WarnIfNoEntitiesDefined(RuntimeConfig)helper and invokes it duringdab validate. - Refactors
IsConfigValidto log the new structural warning regardless of overall validation outcome. - Adds a CLI unit test that verifies the warning is logged for a minimal config with zero entities.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Cli/ConfigGenerator.cs | Introduces and invokes the new “zero entities” warning helper during dab validate. |
| src/Cli.Tests/ValidateConfigTests.cs | Adds a unit test verifying the warning is emitted for an empty-entities config. |
Contributor
|
/azp run |
4bb0609 to
5c93d5e
Compare
Aniruddh25
reviewed
Apr 29, 2026
Aniruddh25
reviewed
Apr 29, 2026
Aniruddh25
reviewed
Apr 29, 2026
Aniruddh25
reviewed
Apr 30, 2026
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
reviewed
May 1, 2026
Aniruddh25
requested changes
May 1, 2026
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
IsRestEnabled check needs to be fixed.
Aniruddh25
approved these changes
May 5, 2026
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
Some tests fail, and some renames necessary.
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?
Closes #3267
What is this change?
Alters the validation logic in the following way.
Is top-level config with data-source-files? (we call this a
Rootconfig file)├── YES
│ ├── Has datasource? → ValidateEntityPresence (same rules as non-root)
│ ├── No datasource but has entities/autoentities? → ERROR
│ └── No datasource, no entities → VALID (children provide everything)
│ └── For each child → ValidateNonRootConfig(child, filename)
│
└── NO (standalone or child config)
├── No datasource? → ERROR: "data source is required"
└── Has datasource → ValidateEntityPresence
Note: A top-level config file without any children data-source files is NOT considered a root. And an intermediary config file, ie: is a child, that also has child configs is NOT a root. Only a top-level config with children configs is a Root.
ValidateEntityPresence
Count resolved autoentities from AutoentityResolutionCounts
total = manual entities + resolved autoentities
total == 0? → ERROR: "No entities found"
total > 0 but autoentities discovered nothing? → WARN: "Autoentities configured but none discovered"
No double messaging. If total is 0, only the error is recorded, not the warning.
How was this tested?
Truth table — top-level config
Variables (
1= present / non-empty,0= absent / empty):data-source-filespresentdata-sourcepresententitiescount > 0autoentitiescount > 0 (presence, not resolved count)Path is determined by
IsRootConfig = (DSF == 1) && !IsChildConfig.TestNonRootWithNoDataSourceProducesErrorTestNonRootWithDataSourceAndNoEntitiesProducesErrorTestNonRootWithDataSourceAndAutoentitiesResolvingZeroProducesErrorTestNonRootWithDataSourceAndAutoentitiesResolvingEntitiesIsValidTestNonRootWithDataSourceAndEntitiesIsValidTestNonRootWithEntitiesAndAutoentitiesResolvingZeroLogsWarningTestRootWithNoDataSourceAndNoEntitiesIsValid,TestRootConfigWithNoDataSourceAndNoEntitiesParsesTestRootWithNoDataSourceButAutoentitiesProducesErrorTestRootWithNoDataSourceButEntitiesProducesErrorTestRootWithDataSourceAndNoEntitiesProducesErrorTestRootWithDataSourceAndAutoentitiesResolvingZeroProducesErrorTestRootWithDataSourceAndAutoentitiesResolvingEntitiesIsValidTestRootWithDataSourceAndEntitiesIsValidTestRootWithEntitiesAndAutoentitiesResolvingZeroLogsWarningTruth table — child config (validated when iterating
root.ChildConfigs)Children are always treated as non-root regardless of their own
data-source-files.TestChildWithNoDataSourceProducesNamedErrorTestChildWithDataSourceAndNoEntitiesProducesNamedErrorTestChildWithDataSourceAndAutoentitiesResolvingZeroProducesNamedErrorTestRootWithDataSourceAndEntitiesIsValidsetupTestChildWithEntitiesAndAutoentitiesResolvingZeroLogsNamedWarningOther scenarios
IsConfigValid == falsedue to connection error onlyTestValidateNonRootZeroEntitiesWithInvalidConnectionStringIsConfigValidreturns false without throwingTestValidateConfigWithNoEntitiesProducesCleanError(modified)IsRootConfig == trueTestRootConfigWithNoDataSourceAndNoEntitiesParsesIsRootConfig == falseTestNonRootConfigWithDataSourceAndNoEntitiesParsesValidateAutoentitiesConfiguration(modified toisValidateOnly: true)New tests:
TestRootConfigWithNoDataSourceAndNoEntitiesParsesRoot config (has data-source-files) without datasource parses OKTestNonRootConfigWithDataSourceAndNoEntitiesParsesNon-root config with datasource + no entities parses OK (validation catches it later)TestNonRootWithDataSourceAndNoEntitiesProducesErrorCalls ValidateDataSourceAndEntityPresence directly, error recordedTestNonRootWithNoDataSourceProducesErrorNo datasource, error with "data source is required"TestNonRootWithDataSourceAndEntitiesIsValidDatasource + entities, no errorsTestRootWithNoDataSourceAndNoEntitiesIsValidRoot with child, no own datasource, validTestRootWithNoDataSourceButEntitiesProducesErrorRoot with entities but no datasource, errorTestRootWithDataSourceAndEntitiesIsValidRoot with own datasource + entities, validTestChildWithDataSourceAndNoEntitiesProducesNamedErrorChild with no entities, error names the child fileTestChildWithNoDataSourceProducesNamedErrorChild with no datasource, error names the child fileTestNonRootWithDataSourceAndAutoentitiesResolvingZeroProducesErrorNon-root with only autoentities that resolve to 0TestNonRootWithDataSourceAndAutoentitiesResolvingEntitiesIsValidNon-root with only autoentities resolving > 0 entitiesTestNonRootWithEntitiesAndAutoentitiesResolvingZeroLogsWarningNon-root with manual entities + autoentities resolving 0TestRootWithNoDataSourceButAutoentitiesProducesErrorRoot with no datasource but autoentities definedTestRootWithDataSourceAndNoEntitiesProducesErrorRoot with own datasource and zero entities/autoentitiesTestRootWithDataSourceAndAutoentitiesResolvingZeroProducesErrorRoot with own datasource and autoentities resolving 0TestRootWithDataSourceAndAutoentitiesResolvingEntitiesIsValidRoot with own datasource and autoentities resolving > 0TestRootWithEntitiesAndAutoentitiesResolvingZeroLogsWarningRoot with own datasource, manual entities, and autoentities resolving 0TestChildWithDataSourceAndAutoentitiesResolvingZeroProducesNamedErrorChild with autoentities-only resolving 0TestChildWithEntitiesAndAutoentitiesResolvingZeroLogsNamedWarningChild with manual entities + autoentities resolving 0Modified tests:
TestValidateConfigWithNoEntitiesProducesCleanErrorReplaced main's version (expected parse failure) with ours: parse succeeds, IsConfigValid returns falseValidateAutoentitiesConfigurationChanged to isValidateOnly: true, asserts no crashes instead of zero errors