Skip to content

Fix Deploy-FinOpsHub version parsing for single-component version strings - #2304

Draft
Michael Flanakin (flanakin) wants to merge 3 commits into
devfrom
fix/2293-deploy-hub-version-parsing
Draft

Fix Deploy-FinOpsHub version parsing for single-component version strings#2304
Michael Flanakin (flanakin) wants to merge 3 commits into
devfrom
fix/2293-deploy-hub-version-parsing

Conversation

@flanakin

Copy link
Copy Markdown
Collaborator

🛠️ Description

Deploy-FinOpsHub casts -Version directly to [version] in several parameter-gating checks (e.g. [version]$Version -ge '0.4') to decide which template parameters to pass. GitHub release tags in this repo are published as single-component strings ("13", "14", "15", ...), and Save-FinOpsHubTemplate -Version "13" correctly resolves and downloads them. But casting that same "13" string to [version] throws:

Cannot convert value "13" to type "System.Version". Error: "Version string portion was too short or too long."

because .NET's [version] parser requires at least a major.minor value. So Deploy-FinOpsHub -Version "13" downloaded the template fine and then crashed immediately after, on the first [version]$Version comparison.

Fix

Added a small private helper, ConvertTo-NormalizedVersion (src/powershell/Private/ConvertTo-NormalizedVersion.ps1), that appends .0 to a version string when it has no .. Deploy-FinOpsHub now computes $normalizedVersion = ConvertTo-NormalizedVersion -Version $Version once, and uses it only in the [version] comparisons (all 7 gate checks, including the NAT Gateway/private-mode minimum-version check). The raw $Version is unchanged everywhere else — most importantly Save-FinOpsHubTemplate -Version $Version, so release tag resolution/download still uses the exact tag name (passing "13.0" there would fail to find a matching release, as confirmed by the reporter).

This mirrors the normalization already used as a test-only helper in src/powershell/Tests/Integration/Toolkit.Tests.ps1 (left untouched, per scope).

Fixes #2293

📷 Screenshots

N/A — PowerShell parameter-parsing fix, no UI change.

📋 Checklist

🔬 How did you test this change?

  • 🤏 Lint tests
  • 🤞 PS -WhatIf / az validate
  • 👍 Manually deployed + verified
  • 💪 Unit tests
  • 🙌 Integration tests

Ran Invoke-ScriptAnalyzer against the changed/added files (Deploy-FinOpsHub.ps1, ConvertTo-NormalizedVersion.ps1, Deploy-FinOpsHub.Tests.ps1) — no new findings introduced by this change. Ran the full Pester unit suite (npm run pester): 2298 passed, 0 failed, including 6 new/extended tests covering -Version "13" (no throw, same parameter set as "13.0"), "12" vs "12.0", and that an already-dotted version like "0.4" still works.

📦 Deploy to test?

(none — no live Azure deployment was performed)

🙋‍♀️ Do any of the following that apply?

  • 🚨 This is a breaking change.
  • 🤏 The change is less than 20 lines of code.

📑 Did you update docs/changelog.md?

  • ✅ Updated changelog (required for dev PRs)
  • ➡️ Will add log in a future PR (feature branch PRs only)
  • ❎ Log not needed (small/internal change)

📖 Did you update documentation?

  • ✅ Public docs in docs (required for dev)
  • ✅ Public docs in docs-mslearn (required for dev)
  • ✅ Internal dev docs in docs-wiki (required for dev)
  • ✅ Internal dev docs in src (required for dev)
  • ➡️ Will add docs in a future PR (feature branch PRs only)
  • ❎ Docs not needed (small/internal change)

🤖 Generated with Claude Code

…-FinOpsHub

GitHub release tags in this repo are published as single-component strings
(e.g. "13", "14", "15"). Deploy-FinOpsHub cast -Version directly to [version]
in several parameter-gating checks, which throws for single-component strings
since .NET's [version] parser requires at least major.minor.

Add a small ConvertTo-NormalizedVersion private helper that appends ".0" when
the version has no dot, and use it only for the [version] comparisons. The
raw -Version value is still passed to Save-FinOpsHubTemplate so release tag
resolution/download is unaffected.

Fixes #2293
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Micro PR 🔬 Very small PR that should be especially easy for newcomers label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Micro PR 🔬 Very small PR that should be especially easy for newcomers Needs: Review 👀 PR that is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running Deploy-FinOpsHub sees - Cannot convert value "13" to type "System.Version". Error

2 participants