Skip to content

Commit 2f1313b

Browse files
Merge pull request #285639 from mumian/0822-bcp063
Add new Bicep diagnostic codes
2 parents 3a55d11 + 1da9199 commit 2f1313b

27 files changed

+884
-38
lines changed

articles/azure-resource-manager/bicep/bicep-core-diagnostics.md

Lines changed: 32 additions & 32 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: BCP007
3+
description: Error - This declaration type isn't recognized. Specify a metadata, parameter, variable, resource, or output declaration.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/23/2024
7+
---
8+
9+
# Bicep error code - BCP007
10+
11+
This error occurs when the declaration type isn't recognized. For a list of declaration types, see [Understand the structure and syntax of Bicep files](../file.md).
12+
13+
## Error description
14+
15+
`This declaration type isn't recognized. Specify a metadata, parameter, variable, resource, or output declaration.`
16+
17+
## Solution
18+
19+
Use the correct declaration type. For more information, see [Bicep file](../file.md).
20+
21+
## Examples
22+
23+
The following example raises the error because `parameter` isn't a correct declaration type:
24+
25+
```bicep
26+
parameter name string
27+
```
28+
29+
You can fix the error by using the correct declaration type, `param`.
30+
31+
```bicep
32+
param name string
33+
```
34+
35+
For more information, see [Parameters](../parameters.md).
36+
37+
## Next steps
38+
39+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: BCP009
3+
description: Error - Expected a literal value, an array, an object, a parenthesized expression, or a function call at this location.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/23/2024
7+
---
8+
9+
# Bicep error code - BCP009
10+
11+
This error occurs when a declaration is not completed.
12+
13+
## Error description
14+
15+
`Expected a literal value, an array, an object, a parenthesized expression, or a function call at this location.`
16+
17+
## Solution
18+
19+
Include the missing part. For more information, see [Bicep file](../file.md).
20+
21+
## Examples
22+
23+
The following example raises the error because the `metadata` declaration isn't completed:
24+
25+
```bicep
26+
metadata description =
27+
```
28+
29+
You can fix the error by using completing the declaration.
30+
31+
```bicep
32+
metadata description = 'Creates a storage account and a web app'
33+
```
34+
35+
For more information, see [Metadata](../file.md#metadata).
36+
37+
## Next steps
38+
39+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).

articles/azure-resource-manager/bicep/diagnostics/bcp018.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ output tennisBall object = {
3737
}
3838
```
3939

40+
For more information, see [Objects](../data-types.md#objects)
41+
4042
The following example raises the error because the code is missing a _]_.
4143

4244
```bicep
@@ -56,6 +58,22 @@ output colors array = [
5658
]
5759
```
5860

61+
For more information, see [Arrays](../data-types.md#arrays).
62+
63+
The following example raises the error because the code is missing `=` and the assigned value.
64+
65+
```bicep
66+
output month int
67+
```
68+
69+
You can fix the error by completing the output declaration.
70+
71+
```bicep
72+
output month int = 3
73+
```
74+
75+
For more information, see [Outputs](../file.md#outputs).
76+
5977
## Next steps
6078

61-
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).
79+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).

articles/azure-resource-manager/bicep/diagnostics/bcp057.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ ms.date: 08/08/2024
88

99
# Bicep error code - BCP057
1010

11-
This error occurs when the referenced name doesn't exist, either because of a typo or because it hasn't been declared.
11+
This error occurs when the referenced name doesn't exist, either due to a typo or because it hasn't been declared. If it's a typo, you'll encounter [BCP082](./bcp082.md) when the compiler identifies and suggests a similarly named symbol.
1212

1313
## Error description
1414

1515
`The name <name> does not exist in the current context.`
1616

1717
## Solution
1818

19-
Fix the typo or declare the name.
19+
Fix the typo or declare the symbol.
2020

2121
## Examples
2222

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: BCP063
3+
description: Error - The name <name> isn't a parameter, variable, resource, or module.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/23/2024
7+
---
8+
9+
# Bicep error code - BCP063
10+
11+
This error occurs when the system tries to locate a name within the context, but no matching name is found.
12+
13+
## Error description
14+
15+
`The name <name> isn't a parameter, variable, resource, or module.`
16+
17+
## Solutions
18+
19+
Use the property declaration types. For more information, see [Bicep file](../file.md).
20+
21+
## Examples
22+
23+
The following example raises the error because *@metadata* is not a correct declaration type:
24+
25+
```bicep
26+
@metadata
27+
resource store 'Microsoft.Storage/storageAccounts@2023-05-01' existing = {
28+
name: 'mystore'
29+
}
30+
```
31+
32+
You can fix the error by properly declaring `metadata`.
33+
34+
```bicep
35+
metadata description = 'create a storage account'
36+
37+
resource store 'Microsoft.Storage/storageAccounts@2023-05-01' existing = {
38+
name: 'mystore'
39+
}
40+
```
41+
42+
For more information, see [Metadata](../file.md#metadata).
43+
44+
## Next steps
45+
46+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: BCP071
3+
description: Error - Expected <arugment-count>, but got <argument-count>.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 07/15/2024
7+
---
8+
9+
# Bicep error code - BCP071
10+
11+
This error occurs when a function is given an incorrect number of arguments. For a list of system defined functions, see [Bicep functions](../bicep-functions-any.md). To define you own functions, see [User-defined functions](../user-defined-functions.md).
12+
13+
## Error description
14+
15+
`Expected <arugment-count>, but got <argument-count>.`
16+
17+
## Solution
18+
19+
Provide the correct number of arguments.
20+
21+
## Examples
22+
23+
The following example raises the error because [`split()`](../bicep-functions-string.md#split) expects two arguments, but three arguments were provided:
24+
25+
```bicep
26+
var tooManyArgs = split('a,b', ',', '?')
27+
```
28+
29+
You can fix the error by removing the extra argument:
30+
31+
```bicep
32+
var tooManyArgs = split('a,b', ',', '?')
33+
```
34+
35+
## Next steps
36+
37+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: BCP082
3+
description: Error/warning - The name <name> doesn't exist in the current context. Did you mean <name>?
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/06/2024
7+
---
8+
9+
# Bicep error/warning code - BCP082
10+
11+
This error or warning is similar to [BCP057](./bcp057.md), it occurs when the referenced name doesn't exist, likely due to a typo. The compiler identifies and suggests a similarly named symbol.
12+
13+
## Error/warning description
14+
15+
`The name <name> doesn't exist in the current context. Did you mean <name>?`
16+
17+
## Solutions
18+
19+
Fix the typo.
20+
21+
## Examples
22+
23+
The following example raises the error because `substirng` looks like a typo.
24+
25+
```bicep
26+
var prefix = substirng('1234567890', 0, 11)
27+
```
28+
29+
You can fix the error by using `substring` instead:
30+
31+
```bicep
32+
var prefix = substring('1234567890', 0, 11)
33+
```
34+
35+
## Next steps
36+
37+
For more information about Bicep error and warning codes, see [Bicep warnings and errors](../bicep-core-diagnostics.md).
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: BCP124
3+
description: Error - The decorator <decorator-name> can only be attached to targets of type <data-type>, but the target has type <data-type>.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/23/2024
7+
---
8+
9+
# Bicep error code - BCP124
10+
11+
This error occurs when you specify a decorator that isn't supported by the type of the syntax being decorated.
12+
13+
## Error description
14+
15+
`The decorator <decorator-name> can only be attached to targets of type <data-type>, but the target has type <data-type>.`
16+
17+
## Solutions
18+
19+
Use the valid decorators based on the data types.
20+
21+
## Examples
22+
23+
The following example raises the error because `@maxValue()` is for the integer data type, not for the string data type.
24+
25+
```bicep
26+
@maxValue(3)
27+
param name string
28+
```
29+
30+
You can fix the error by providing the correct decorator for the data type:
31+
32+
```bicep
33+
@maxLength(3)
34+
param name string
35+
```
36+
37+
For a list of decorators, see [Decorators](../file.md#decorators).
38+
39+
## Next steps
40+
41+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: BCP125
3+
description: Error - Function <function-name> can't be used as a parameter decorator.
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 08/23/2024
7+
---
8+
9+
# Bicep error code - BCP125
10+
11+
This error occurs when you specify an invalid parameter decorator.
12+
13+
## Error description
14+
15+
`Function <function-name> can't be used as a parameter decorator.`
16+
17+
## Solutions
18+
19+
Use the valid decorators for parameter declarations. For more information, see [Decorators](../parameters.md#use-decorators).
20+
21+
## Examples
22+
23+
The following example raises the error because `@export()` isn't a valid decorator for parameters.
24+
25+
```bicep
26+
@export()
27+
param name string
28+
```
29+
30+
You can fix the error by providing the correct decorator for parameters:
31+
32+
```bicep
33+
@description('Specify the resource name.')
34+
param name string
35+
```
36+
37+
## Next steps
38+
39+
For more information about Bicep error and warning codes, see [Bicep core diagnostics](../bicep-core-diagnostics.md).

0 commit comments

Comments
 (0)