Closed Aniruddh25 closed 1 month ago
Does "$schema": "https://dataapibuilder.azureedge.net/schemas/v0.5.34/dab.draft.schema.json",
not cause issues with JSON validation given that the version used is 0.5.34 instead of "$schema": "https://github.com/Azure/data-api-builder/releases/download/v0.12.0-rc/dab.draft.schema.json",
I get a different stack trace:
Information: Validating entity relationships. Unhandled exception. System.AggregateException: One or more errors occurred. (The given key 'Publisher' was not present in the dictionary.) ---> System.Collections.Generic.KeyNotFoundException: The given key 'Publisher' was not present in the dictionary. at System.Collections.Generic.Dictionary
2.get_Item(TKey key) at Azure.DataApiBuilder.Core.Services.SqlMetadataProvider
3.TryGetBackingColumn(String entityName, String field, String& name) in //src/Core/Services/MetadataProviders/SqlMetadataProvider.cs:line 220 at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.GetFieldsNotBackedByColumnsInDB(List`1 invalidColumns, String[] fields, String entityName, ISqlMetadataProvider sqlMetadataProvider) in //src/Core/Configurations/RuntimeConfigValidator.cs:line 1093 at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.ValidateRelationshipsInConfig(RuntimeConfig runtimeConfig, IMetadataProviderFactory sqlMetadataProviderFactory) in //src/Core/Configurations/RuntimeConfigValidator.cs:line 875 at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.ValidateEntitiesMetadata(RuntimeConfig runtimeConfig, ILoggerFactory loggerFactory) in //src/Core/Configurations/RuntimeConfigValidator.cs:line 232 at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.TryValidateConfig(String configFilePath, ILoggerFactory loggerFactory) in /_/src/Core/Configurations/RuntimeConfigValidator.cs:line 169
This issue looks like it stems from collections in the metadataprovider not being fully populated at time of validation:
this was not caught presumably because it doesn't occur on dab start
and only appears during dab validate
This seems to be caused by SqlMetadataProvider::GenerateExposedToBackingColumnMapsForEntities()
being outside the scope of _isValidateOnly
code.
The above comment holds true when the dab-config.json
you provide to dab validate --config "path"
has an invalid connection string. Because dab validate
accumulates all errors instead of halting at first error, it attempts to find out everything wrong with the config. That won't work when dab can't connect to the database and proceed to validate your config against db metadata.
@Aniruddh25 , can you confirm whether your config had a valid connection string or if you were using an environment variable placeholder for your connection string?
Agreed that the error message isn't helpful so one path forward here is:
The above comment holds true when the
dab-config.json
you provide todab validate --config "path"
has an invalid connection string. Becausedab validate
accumulates all errors instead of halting at first error, it attempts to find out everything wrong with the config. That won't work when dab can't connect to the database and proceed to validate your config against db metadata.@Aniruddh25 , can you confirm whether your config had a valid connection string or if you were using an environment variable placeholder for your connection string?
Agreed that the error message isn't helpful so one path forward here is:
- halt validation when the connection string is invalid/can't connect to DB. When DAB can't connect to DB, DAB can't confirm whether config is correct. (@abhishekkumams , thoughts?
I found the same in my investiation. This only arises when the connection string is invalid. My thought was to add a try catch to the validation steps that rely on the connection string and then some messaging to help explain the problem.
What happened?
Cannot figure out what's wrong with this sample config. Doing
dab validate
causes anUnhandled Exception
with the stack trace as provided in the log output.Version
0.12.0-rc
What database are you using?
Azure SQL
What hosting model are you using?
Local (including CLI)
Which API approach are you accessing DAB through?
No response
Relevant log output
Code of Conduct