Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify wording for BCP081 warning #13739

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Bicep.Core.IntegrationTests/CompileTimeImportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,7 @@ public void Resource_derived_typed_compile_time_imports_raise_diagnostic_when_im

result.Should().HaveDiagnostics(new[]
{
("BCP081", DiagnosticLevel.Warning, """Resource type "Microsoft.Foo/bars@2022-09-01" does not have types available."""),
("BCP081", DiagnosticLevel.Warning, """Resource type "Microsoft.Foo/bars@2022-09-01" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."""),
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core.IntegrationTests/ExamplesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private static bool IsPermittedMissingTypeDiagnostic(IDiagnostic diagnostic)
var permittedMissingTypeDiagnostics = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
// To exclude a particular type for BCP081 (if there are missing types), add an entry of format:
// "Resource type \"<type>\" does not have types available.",
// "Resource type \"<type>\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed.",
};

return permittedMissingTypeDiagnostics.Contains(diagnostic.Message);
Expand Down
8 changes: 4 additions & 4 deletions src/Bicep.Core.IntegrationTests/ExtensibilityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public void Kubernetes_CustomResourceType_EmitWarning()

result.Should().GenerateATemplate();
result.Should().HaveDiagnostics(new[] {
("BCP081", DiagnosticLevel.Warning, @"Resource type ""custom/Foo@v1"" does not have types available."),
("BCP081", DiagnosticLevel.Warning, @"Resource type ""custom/Foo@v1"" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
});
}

Expand Down Expand Up @@ -397,8 +397,8 @@ public void Kubernetes_AmbiguousFallbackType_MustFullyQualify()
result.Should().HaveDiagnostics(new[] {
("BCP264", DiagnosticLevel.Error, @"Resource type ""Microsoft.Compute/availabilitySets@2023-01-01"" is declared in multiple imported namespaces (""az"", ""kubernetes""), and must be fully-qualified."),
("BCP035", DiagnosticLevel.Error, @"The specified ""resource"" declaration is missing the following required properties: ""name""."),
("BCP081", DiagnosticLevel.Warning, @"Resource type ""Microsoft.Compute/availabilitySets@2023-01-01"" does not have types available."),
("BCP081", DiagnosticLevel.Warning, @"Resource type ""Microsoft.Foo/bar@2023-01-01"" does not have types available."),
("BCP081", DiagnosticLevel.Warning, @"Resource type ""Microsoft.Compute/availabilitySets@2023-01-01"" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP081", DiagnosticLevel.Warning, @"Resource type ""Microsoft.Foo/bar@2023-01-01"" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
});
}

Expand Down Expand Up @@ -466,7 +466,7 @@ public void Child_resource_with_parent_namespace_mismatch_returns_error()
");

result.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[] {
("BCP081", DiagnosticLevel.Warning, "Resource type \"Microsoft.Storage/storageAccounts@2020-01-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Microsoft.Storage/storageAccounts@2020-01-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP210", DiagnosticLevel.Error, "Resource type belonging to namespace \"stg\" cannot have a parent resource type belonging to different namespace \"az\"."),
});
}
Expand Down
10 changes: 5 additions & 5 deletions src/Bicep.Core.IntegrationTests/ModuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,14 +657,14 @@ public void Module_with_unknown_resourcetype_as_parameter_and_output_has_diagnos
{
diagnosticsMap[InMemoryFileResolver.GetFileUri("/path/to/module.bicep")].Should().HaveDiagnostics(new[]
{
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Another.Fake/Type@2019-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Another.Fake/Type@2019-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Another.Fake/Type@2019-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Another.Fake/Type@2019-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
});
diagnosticsMap[InMemoryFileResolver.GetFileUri("/path/to/main.bicep")].Should().HaveDiagnostics(new[]
{
("BCP230", DiagnosticLevel.Warning, "The referenced module uses resource type \"Some.Fake/Type@2019-06-01\" which does not have types available."),
("BCP230", DiagnosticLevel.Warning, "The referenced module uses resource type \"Another.Fake/Type@2019-06-01\" which does not have types available."),
("BCP230", DiagnosticLevel.Warning, "The referenced module uses resource type \"Some.Fake/Type@2019-06-01\" which does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP230", DiagnosticLevel.Warning, "The referenced module uses resource type \"Another.Fake/Type@2019-06-01\" which does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP036", DiagnosticLevel.Error, "The property \"p\" expected a value of type \"Some.Fake/Type\" but the provided value is of type \"'something'\"."),
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/Bicep.Core.IntegrationTests/OutputsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ public void Output_can_have_warnings_for_missing_type()
result.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[]
{
// There are two warnings because there are two places in code to correct the missing type.
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
});
}

Expand All @@ -226,7 +226,7 @@ public void Output_can_have_warnings_for_missing_type_but_we_dont_duplicate_them

result.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[]
{
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/Bicep.Core.IntegrationTests/ParametersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void Parameter_can_have_warnings_for_missing_type()
");
result.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[]
{
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Some.Fake/Type@2019-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
});
}

Expand Down Expand Up @@ -204,7 +204,7 @@ public void Parameter_with_resource_type_cannot_be_used_as_extension_scope()

result.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[]
{
("BCP081", DiagnosticLevel.Warning, "Resource type \"My.Rp/myResource@2020-01-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"My.Rp/myResource@2020-01-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP229", DiagnosticLevel.Error, "The parameter \"p\" cannot be used as a resource scope or parent. Resources passed as parameters cannot be used as a scope or parent of a resource."),
});
}
Expand All @@ -227,7 +227,7 @@ public void Parameter_with_resource_type_cannot_be_used_as_parent()

result.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[]
{
("BCP081", DiagnosticLevel.Warning, "Resource type \"Microsoft.Storage/storageAccounts/tableServices@2020-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Microsoft.Storage/storageAccounts/tableServices@2020-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP229", DiagnosticLevel.Error, "The parameter \"p\" cannot be used as a resource scope or parent. Resources passed as parameters cannot be used as a scope or parent of a resource."),
("BCP169", DiagnosticLevel.Error, "Expected resource name to contain 1 \"/\" character(s). The number of name segments must match the number of segments in the resource type."),
});
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core.IntegrationTests/RegistryProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public async Task Warning_generated_and_fallback_type_type_accepted()
result.Template.Should().HaveValueAtPath("$.resources['dadJoke']['properties']['bodyProp']", "fallback body");

result.Should().HaveDiagnostics(new[]{
("BCP081", DiagnosticLevel.Warning, "Resource type \"test@v1\" does not have types available.")
("BCP081", DiagnosticLevel.Warning, "Resource type \"test@v1\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed.")
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,9 +1060,9 @@ public void Test_Issue1941()
result.Template.Should().NotBeNull();
result.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[]
{
("BCP081", DiagnosticLevel.Warning, "Resource type \"Rp.A/providers@2020-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Rp.A/providers/a/b@2020-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Rp.A/a/b/providers@2020-06-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Rp.A/providers@2020-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Rp.A/providers/a/b@2020-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Rp.A/a/b/providers@2020-06-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
});

result = CompilationHelper.Compile(@"
Expand Down Expand Up @@ -3305,7 +3305,7 @@ public void Test_Issue_3356_Warn_On_Bad_Type_Definitions()
");
result.ExcludingLinterDiagnostics().Should().HaveDiagnostics(new[]
{
("BCP081", DiagnosticLevel.Warning, "Resource type \"Microsoft.Storage/storageAccounts@2021-09-00\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"Microsoft.Storage/storageAccounts@2021-09-00\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP036", DiagnosticLevel.Warning, "The property \"name\" expected a value of type \"string\" but the provided value is of type \"123\". If this is an inaccuracy in the documentation, please report it to the Bicep Team."),
("BCP036", DiagnosticLevel.Warning, "The property \"capacity\" expected a value of type \"int\" but the provided value is of type \"'1'\". If this is an inaccuracy in the documentation, please report it to the Bicep Team."),
("BCP036", DiagnosticLevel.Warning, "The property \"type\" expected a value of type \"string\" but the provided value is of type \"1\". If this is an inaccuracy in the documentation, please report it to the Bicep Team."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ public void ObjectVariablesWithUnknownTypeResourceReference_ShouldBeInlined()
"));

result.ExcludingLinterDiagnostics().Should().GenerateATemplate().And.HaveDiagnostics(new[] {
("BCP081", DiagnosticLevel.Warning, "Resource type \"My.Rp/myResourceType@2020-01-01\" does not have types available."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"My.Rp/myResourceType@2020-01-01\" does not have types available.")
("BCP081", DiagnosticLevel.Warning, "Resource type \"My.Rp/myResourceType@2020-01-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed."),
("BCP081", DiagnosticLevel.Warning, "Resource type \"My.Rp/myResourceType@2020-01-01\" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed.")
});
using (new AssertionScope())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var resourceDependency = {

output resourceAType string = resA.type
resource resA 'My.Rp/myResourceType@2020-01-01' = {
//@[14:47) [BCP081 (Warning)] Resource type "My.Rp/myResourceType@2020-01-01" does not have types available. (CodeDescription: none) |'My.Rp/myResourceType@2020-01-01'|
//@[14:47) [BCP081 (Warning)] Resource type "My.Rp/myResourceType@2020-01-01" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed. (CodeDescription: none) |'My.Rp/myResourceType@2020-01-01'|
name: 'resA'
properties: {
deployTime: dependentVar
Expand All @@ -29,7 +29,7 @@ resource resA 'My.Rp/myResourceType@2020-01-01' = {

output resourceBId string = resB.id
resource resB 'My.Rp/myResourceType@2020-01-01' = {
//@[14:47) [BCP081 (Warning)] Resource type "My.Rp/myResourceType@2020-01-01" does not have types available. (CodeDescription: none) |'My.Rp/myResourceType@2020-01-01'|
//@[14:47) [BCP081 (Warning)] Resource type "My.Rp/myResourceType@2020-01-01" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed. (CodeDescription: none) |'My.Rp/myResourceType@2020-01-01'|
name: 'resB'
properties: {
dependencies: resourceDependency
Expand All @@ -42,23 +42,23 @@ var resourceIds = {
}

resource resC 'My.Rp/myResourceType@2020-01-01' = {
//@[14:47) [BCP081 (Warning)] Resource type "My.Rp/myResourceType@2020-01-01" does not have types available. (CodeDescription: none) |'My.Rp/myResourceType@2020-01-01'|
//@[14:47) [BCP081 (Warning)] Resource type "My.Rp/myResourceType@2020-01-01" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed. (CodeDescription: none) |'My.Rp/myResourceType@2020-01-01'|
name: 'resC'
properties: {
resourceIds: resourceIds
}
}

resource resD 'My.Rp/myResourceType/childType@2020-01-01' = {
//@[14:57) [BCP081 (Warning)] Resource type "My.Rp/myResourceType/childType@2020-01-01" does not have types available. (CodeDescription: none) |'My.Rp/myResourceType/childType@2020-01-01'|
//@[14:57) [BCP081 (Warning)] Resource type "My.Rp/myResourceType/childType@2020-01-01" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed. (CodeDescription: none) |'My.Rp/myResourceType/childType@2020-01-01'|
name: '${resC.name}/resD'
//@[08:27) [use-parent-property (Warning)] Resource "resD" has its name formatted as a child of resource "resC". The syntax can be simplified by using the parent property. (CodeDescription: bicep core(https://aka.ms/bicep/linter/use-parent-property)) |'${resC.name}/resD'|
properties: {
}
}

resource resE 'My.Rp/myResourceType/childType@2020-01-01' = {
//@[14:57) [BCP081 (Warning)] Resource type "My.Rp/myResourceType/childType@2020-01-01" does not have types available. (CodeDescription: none) |'My.Rp/myResourceType/childType@2020-01-01'|
//@[14:57) [BCP081 (Warning)] Resource type "My.Rp/myResourceType/childType@2020-01-01" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed. (CodeDescription: none) |'My.Rp/myResourceType/childType@2020-01-01'|
name: 'resC/resD'
//@[08:19) [use-parent-property (Warning)] Resource "resE" has its name formatted as a child of resource "resC". The syntax can be simplified by using the parent property. (CodeDescription: bicep core(https://aka.ms/bicep/linter/use-parent-property)) |'resC/resD'|
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ param paramModifierSelfCycle string
// wrong types of "variable"/identifier access
var sampleVar = 'sample'
resource sampleResource 'Microsoft.Foo/foos@2020-02-02' = {
//@[24:055) [BCP081 (Warning)] Resource type "Microsoft.Foo/foos@2020-02-02" does not have types available. (CodeDescription: none) |'Microsoft.Foo/foos@2020-02-02'|
//@[24:055) [BCP081 (Warning)] Resource type "Microsoft.Foo/foos@2020-02-02" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed. (CodeDescription: none) |'Microsoft.Foo/foos@2020-02-02'|
name: 'foo'
}
output sampleOutput string = 'hello'
Expand Down