Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Cli.Tests/ValidateConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,6 @@ public void ValidateConfigSchemaWhereConfigReferencesEnvironmentVariables()
Assert.IsFalse(
condition: loggerOutput.Contains("Failed to validate config against schema due to"),
message: "Unexpected errors encountered when validating config schema in RuntimeConfigValidator::ValidateConfigSchema(...).");
Assert.IsTrue(
condition: loggerOutput.Contains("The config satisfies the schema requirements."),
message: "RuntimeConfigValidator::ValidateConfigSchema(...) didn't communicate successful config schema validation.");
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/Commands/ValidateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public int Handler(ILogger logger, FileSystemRuntimeConfigLoader loader, IFileSy
}
else
{
logger.LogError("Config is invalid.");
logger.LogInformation("Config is invalid.");
Comment thread
RubenCerna2079 marked this conversation as resolved.
}

return isValidConfig ? CliReturnCode.SUCCESS : CliReturnCode.GENERAL_ERROR;
Expand Down
13 changes: 9 additions & 4 deletions src/Cli/ConfigGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3166,8 +3166,6 @@ public static bool IsConfigValid(ValidateOptions options, FileSystemRuntimeConfi
return false;
}

_logger.LogInformation("Validating config file: {runtimeConfigFile}", runtimeConfigFile);

RuntimeConfigProvider runtimeConfigProvider = new(loader);

Comment thread
RubenCerna2079 marked this conversation as resolved.
if (!runtimeConfigProvider.TryGetConfig(out RuntimeConfig? _))
Expand Down Expand Up @@ -3196,14 +3194,21 @@ public static bool IsConfigValid(ValidateOptions options, FileSystemRuntimeConfi
bool mcpEnabled = config.IsMcpEnabled;
if (mcpEnabled)
{
bool missingFields = false;
foreach (KeyValuePair<string, Entity> entity in config.Entities)
{
if (entity.Value.Fields == null || !entity.Value.Fields.Any())
{
_logger.LogWarning($"Entity '{entity.Key}' is missing 'fields' definition while MCP is enabled. " +
"It's recommended to define fields explicitly to ensure optimal performance with MCP.");
missingFields = true;
_logger.LogDebug($"Entity '{entity.Key}' is missing 'fields' definition while MCP is enabled.");
}
}

if (missingFields)
{
_logger.LogWarning($"One or more entities are missing `fields` definition while MCP is enabled. " +
Comment thread
RubenCerna2079 marked this conversation as resolved.
Outdated
"It's recommended to define fields explicitly to ensure optimal performance with MCP.");
}
}

// Warn if Unauthenticated provider is used with authenticated or custom roles
Expand Down
1 change: 0 additions & 1 deletion src/Core/Configurations/JsonConfigSchemaValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public JsonSchemaValidationResult ValidateJsonConfigWithSchema(string jsonSchema

if (isValid)
{
_logger!.LogInformation("The config satisfies the schema requirements.");
return new(isValid: true, errors: null);
}
else
Expand Down
1 change: 0 additions & 1 deletion src/Core/Configurations/RuntimeConfigValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ public async Task<bool> TryValidateConfig(
ValidateConfigProperties();
ValidatePermissionsInConfig(runtimeConfig);

_logger.LogInformation("Validating entity relationships.");
ValidateRelationshipConfigCorrectness(runtimeConfig);

// This function initializes the metadata providers which in turn validates the connectivity to the
Expand Down
25 changes: 17 additions & 8 deletions src/Core/Services/MetadataProviders/MsSqlMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,19 @@ public override async Task PopulateTriggerMetadataForTable(string entityName, st
if ("UPDATE".Equals(type_desc))
{
sourceDefinition.IsUpdateDMLTriggerEnabled = true;
_logger.LogInformation($"An update trigger is enabled for the entity: {entityName}");
if (!_isValidateOnly)
{
_logger.LogInformation($"An update trigger is enabled for the entity: {entityName}");
}
}

if ("INSERT".Equals(type_desc))
{
sourceDefinition.IsInsertDMLTriggerEnabled = true;
_logger.LogInformation($"An insert trigger is enabled for the entity: {entityName}");
if (!_isValidateOnly)
{
_logger.LogInformation($"An insert trigger is enabled for the entity: {entityName}");
}
}
}
}
Expand Down Expand Up @@ -362,13 +368,16 @@ protected override async Task GenerateAutoentitiesIntoEntities(IReadOnlyDictiona
subStatusCode: DataApiBuilderException.SubStatusCodes.ErrorInInitialization);
}

if (runtimeConfig.IsRestEnabled)
if (!_isValidateOnly)
Comment thread
RubenCerna2079 marked this conversation as resolved.
Outdated
{
_logger.LogInformation("[{entity}] REST path: {globalRestPath}/{entityRestPath}", entityName, runtimeConfig.RestPath, entityName);
}
else
{
_logger.LogInformation(message: "REST calls are disabled for the entity: {entity}", entityName);
if (runtimeConfig.IsRestEnabled)
{
_logger.LogInformation("[{entity}] REST path: {globalRestPath}/{entityRestPath}", entityName, runtimeConfig.RestPath, entityName);
}
else
{
_logger.LogInformation(message: "REST calls are disabled for the entity: {entity}", entityName);
Comment thread
RubenCerna2079 marked this conversation as resolved.
Outdated
}
}

addedEntities++;
Expand Down
19 changes: 11 additions & 8 deletions src/Core/Services/MetadataProviders/SqlMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,19 @@ public SqlMetadataProvider(
_databaseType = runtimeConfig.GetDataSourceFromDataSourceName(dataSourceName).DatabaseType;
_logger = logger;
_isValidateOnly = isValidateOnly;
foreach ((string entityName, Entity entityMetatdata) in Entities)
if (!_isValidateOnly)
{
if (runtimeConfig.IsRestEnabled)
foreach ((string entityName, Entity entityMetatdata) in Entities)
{
string restPath = entityMetatdata.Rest?.Path ?? entityName;
_logger.LogInformation("[{entity}] REST path: {globalRestPath}/{entityRestPath}", entityName, runtimeConfig.RestPath, restPath);
}
else
{
_logger.LogInformation(message: "REST calls are disabled for the entity: {entity}", entityName);
if (runtimeConfig.IsRestEnabled)
{
string restPath = entityMetatdata.Rest?.Path ?? entityName;
_logger.LogInformation("[{entity}] REST path: {globalRestPath}/{entityRestPath}", entityName, runtimeConfig.RestPath, restPath);
}
else
{
_logger.LogInformation(message: "REST calls are disabled for the entity: {entity}", entityName);
}
Comment thread
RubenCerna2079 marked this conversation as resolved.
Outdated
}
}

Expand Down
24 changes: 0 additions & 24 deletions src/Service.Tests/Configuration/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1874,14 +1874,6 @@ public void TestConfigSchemaIsValid()
JsonSchemaValidationResult result = jsonSchemaValidator.ValidateJsonConfigWithSchema(jsonSchema, jsonData);
Assert.IsTrue(result.IsValid);
Assert.IsTrue(EnumerableUtilities.IsNullOrEmpty(result.ValidationErrors));
schemaValidatorLogger.Verify(
x => x.Log(
LogLevel.Information,
It.IsAny<EventId>(),
It.Is<It.IsAnyType>((o, t) => o.ToString()!.Contains($"The config satisfies the schema requirements.")),
It.IsAny<Exception>(),
(Func<It.IsAnyType, Exception, string>)It.IsAny<object>()),
Times.Once);
}

/// <summary>
Expand All @@ -1906,14 +1898,6 @@ public void TestBasicConfigSchemaWithNoOptionalFieldsIsValid(string jsonData)
Assert.IsTrue(EnumerableUtilities.IsNullOrEmpty(result.ValidationErrors));

Assert.IsTrue(result.IsValid);
schemaValidatorLogger.Verify(
x => x.Log(
LogLevel.Information,
It.IsAny<EventId>(),
It.Is<It.IsAnyType>((o, t) => o.ToString()!.Contains($"The config satisfies the schema requirements.")),
It.IsAny<Exception>(),
(Func<It.IsAnyType, Exception, string>)It.IsAny<object>()),
Times.Once);
}

[DataTestMethod]
Expand All @@ -1940,14 +1924,6 @@ public void TestBasicConfigSchemaWithFlexibleBoolean(string Value)
Assert.IsTrue(EnumerableUtilities.IsNullOrEmpty(result.ValidationErrors), "Validation Erros null of empty");

Assert.IsTrue(result.IsValid, "Result should be valid");
schemaValidatorLogger.Verify(
x => x.Log(
LogLevel.Information,
It.IsAny<EventId>(),
It.Is<It.IsAnyType>((o, t) => o.ToString()!.Contains($"The config satisfies the schema requirements.")),
It.IsAny<Exception>(),
(Func<It.IsAnyType, Exception, string>)It.IsAny<object>()),
Times.Once);
}

/// <summary>
Expand Down