Skip to content

Commit d6eb6d1

Browse files
(DOCS) Document fix to int() function.
In #438 we changed the `int()` function to error on input that isn't a string or an integer to align with the behavior of the ARM template function. This change: - Updates the documentation for the function to match the updated behavior and removing the note about the now-patched bug. - Adds an entry for the fix to the changelog.
1 parent 8f8311f commit d6eb6d1

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ the correct permissions to manage that resource instance.
202202

203203
</details>
204204

205-
206205
### Fixed
207206

208207
- Fixed the JSON Schema for [exit codes][ur-fa] in the resource manifest to support negative
@@ -216,6 +215,19 @@ the correct permissions to manage that resource instance.
216215

217216
</details>
218217

218+
- Fixed the behavior of the [int()][int()] configuration function to error when given an input
219+
value other than a string or integer. Prior to this release, when you specified a number with
220+
a fractional part as input for the function, it coerced the input value to an integer representing
221+
the fractional part. Starting with this release, the `int()` function raises an invalid input
222+
error when the input value isn't a string or an integer.
223+
224+
<details><summary>Related work items</summary>
225+
226+
- Issues: [#390][#390]
227+
- PRs: [#438][#438]
228+
229+
</details>
230+
219231
<!-- Unreleased change links -->
220232
[ur-aa]: ./docs/reference/cli/config/set.md#-w---what-if
221233
[ur-ab]: ./docs/reference/schemas/outputs/config/set.md
@@ -1481,6 +1493,7 @@ For the full list of changes in this release, see the [diff on GitHub][compare-v
14811493
[#382]: https://github.com/PowerShell/DSC/issues/382
14821494
[#385]: https://github.com/PowerShell/DSC/issues/385
14831495
[#388]: https://github.com/PowerShell/DSC/issues/388
1496+
[#390]: https://github.com/PowerShell/DSC/issues/390
14841497
[#397]: https://github.com/PowerShell/DSC/issues/397
14851498
[#400]: https://github.com/PowerShell/DSC/issues/400
14861499
[#401]: https://github.com/PowerShell/DSC/issues/401
@@ -1491,6 +1504,7 @@ For the full list of changes in this release, see the [diff on GitHub][compare-v
14911504
[#429]: https://github.com/PowerShell/DSC/issues/429
14921505
[#432]: https://github.com/PowerShell/DSC/issues/432
14931506
[#434]: https://github.com/PowerShell/DSC/issues/434
1507+
[#438]: https://github.com/PowerShell/DSC/issues/438
14941508
[#45]: https://github.com/PowerShell/DSC/issues/45
14951509
[#49]: https://github.com/PowerShell/DSC/issues/49
14961510
[#57]: https://github.com/PowerShell/DSC/issues/57

docs/reference/schemas/config/functions/int.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Reference for the 'int' DSC configuration document function
3-
ms.date: 04/09/2024
3+
ms.date: 06/13/2024
44
ms.topic: reference
55
title: int
66
---
@@ -9,7 +9,7 @@ title: int
99

1010
## Synopsis
1111

12-
Returns an integer from an input string or non-integer number.
12+
Returns an integer from an input string or integer.
1313

1414
## Syntax
1515

@@ -19,8 +19,9 @@ int(<inputValue>)
1919

2020
## Description
2121

22-
The `int()` function returns an integer, converting an input string or non-integer number into an
23-
integer. It truncates the fractional part of the input number, it doesn't round up.
22+
The `int()` function returns an integer, converting an input string into an integer. If you pass an
23+
integer, it returns the integer. If you pass any other value, including a non-integer number, the
24+
function raises an invalid input error.
2425

2526
## Examples
2627

@@ -57,17 +58,12 @@ hadErrors: false
5758
5859
### inputValue
5960
60-
The `int()` function expects input as either a string or a number. If the value is a string that
61-
can't be parsed as a number, DSC returns an error for the function.
62-
63-
> [!NOTE]
64-
> There is an open bug (see [GitHub issue #390][#390]) for this function when operating on numbers.
65-
> The function correctly returns the expected value for string representations of numbers with
66-
> fractional parts, but returns the fractional part instead of the integer for actual numbers.
67-
> Specify the input value for this function as a string instead of a number.
61+
The `int()` function expects input as either a string or an integer. If the value is a string that
62+
can't be parsed as a number DSC returns an error for the function. If the value isn't a string or
63+
integer, DSC returns an invalid input error for the function.
6864

6965
```yaml
70-
Type: [String, Number]
66+
Type: [String, Integer]
7167
Required: true
7268
MinimumCount: 1
7369
MaximumCount: 1
@@ -84,4 +80,3 @@ Type: integer
8480
```
8581

8682
<!-- Link reference definitions -->
87-
[#390]: https://github.com/PowerShell/DSC/issues/390

0 commit comments

Comments
 (0)