Fix dab validate error messaging when logger is not available#3311
Open
aaronburtle wants to merge 18 commits intomainfrom
Open
Fix dab validate error messaging when logger is not available#3311aaronburtle wants to merge 18 commits intomainfrom
aaronburtle wants to merge 18 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the CLI experience for dab validate / dab start when config parsing fails by surfacing a clean, user-focused error message (instead of dumping exception details/stack traces), and updates tests to match the new output.
Changes:
- Add a mechanism (
RuntimeConfigLoader.LastParseError) to capture the last config parse error message for callers (CLI) to display cleanly. - Update CLI config loading/validation paths to log the captured parse error and (for validate) suppress raw
Console.Erroroutput during config loading. - Update CLI and service/CLI tests to assert the new single-line/clean error behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Config/RuntimeConfigLoader.cs | Captures last parse error and changes exception handling output/logging behavior. |
| src/Cli/ConfigGenerator.cs | Uses LastParseError when config load fails; suppresses Console.Error during validation config load. |
| src/Cli/Commands/ValidateOptions.cs | Changes “Config is invalid” message severity/output format. |
| src/Cli.Tests/ValidateConfigTests.cs | Adds regression coverage ensuring clean error messages (no stack traces) for missing entities/autoentities. |
| src/Cli.Tests/EnvironmentTests.cs | Updates stderr assertions for new clean error format. |
| src/Cli.Tests/EndToEndTests.cs | Removes outdated assertions in ignored test to align with new behavior. |
| src/Service.Tests/Configuration/RuntimeConfigLoaderTests.cs | Updates assertions to validate clean error output without stack traces. |
Contributor
Author
|
@copilot can you do another PR review please. |
Co-authored-by: aaronburtle <93220300+aaronburtle@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/data-api-builder/sessions/5aec902b-92d0-4b71-ba4b-32ca2c049908
Contributor
souvikghosh04
left a comment
There was a problem hiding this comment.
posting comments so far
Copilot stopped work on behalf of
aaronburtle due to an error
April 3, 2026 05:58
Copilot stopped work on behalf of
aaronburtle due to an error
April 3, 2026 06:00
…ithub.com:Azure/data-api-builder into dev/aaronburtle/fix-schema-validation-no-entities
…ithub.com:Azure/data-api-builder into dev/aaronburtle/fix-schema-validation-no-entities
Aniruddh25
reviewed
Apr 3, 2026
Aniruddh25
reviewed
Apr 3, 2026
Aniruddh25
reviewed
Apr 3, 2026
Aniruddh25
reviewed
Apr 3, 2026
Aniruddh25
requested changes
Apr 3, 2026
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
Waiting on merge with #3318
Aniruddh25
approved these changes
Apr 7, 2026
souvikghosh04
approved these changes
Apr 8, 2026
Contributor
souvikghosh04
left a comment
There was a problem hiding this comment.
LGTM. thanks for addressing the comments
3 tasks
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 #3268
What is this change?
When
dab validateordab startencounters a config parsing error (e.g. missing entities/autoentities), the CLI previously dumped the full exception message and stack trace to stderr. This made the output noisy and unhelpful. After this change, only a clean, descriptive validation message is shown.The key design changes:
TryParseConfigis now a pure function that returns anout string? parseErrormessage on failure instead of writing toConsole.ErrororILoggerinternally. Error reporting is the caller's responsibility.FileSystemRuntimeConfigLoader.TryLoadConfigwrites theparseErrortoConsole.Error(because config is parsed before the DI container and logger are available, so the log buffer would never be flushed on a parse failure) and sets an instance-scopedIsParseErrorEmittedflag so CLI callers (ConfigGenerator) can avoid logging duplicate messages.ConfigGenerator.IsConfigValidnow has an explicit early-return path when config parsing fails (viaruntimeConfigProvider.TryGetConfig), usingIsParseErrorEmittedto suppress duplicate output.ValidateOptions.HandlerusesLogError("Config is invalid.").Console.Errorcorrected toTryLoadConfig(notTryParseConfig).How was this tested?
ValidateConfigTests.cs— AddedTestValidateConfigWithNoEntitiesProducesCleanError(new test verifying clean error message, no stack traces).EnvironmentTests.cs— UpdatedFailureToStartEngineWhenEnvVarNamedWrongto match the new single-line clean stderr format.EndToEndTests.cs— Simplified assertions inTestExitOfRuntimeEngineWithInvalidConfig(this test is Ignored but updated for consistency).RuntimeConfigLoaderTests.cs— UpdatedFailLoadMultiDataSourceConfigDuplicateEntitiesto assertloader.IsParseErrorEmittedis true.