Skip to content

Refactor input validation in New-AsBuiltConfig, New-AsBuiltReport, and New-AsBuiltReportConfig scripts#73

Open
rebelinux wants to merge 2 commits intoAsBuiltReport:devfrom
rebelinux:dev
Open

Refactor input validation in New-AsBuiltConfig, New-AsBuiltReport, and New-AsBuiltReportConfig scripts#73
rebelinux wants to merge 2 commits intoAsBuiltReport:devfrom
rebelinux:dev

Conversation

@rebelinux
Copy link
Copy Markdown
Contributor

Refactor input validation in New-AsBuiltConfig, New-AsBuiltReport, and New-AsBuiltReportConfig scripts

  • Updated string comparisons from "" to '' for consistency and clarity.
  • Enhanced validation logic for user inputs in various prompts to ensure default values are set correctly.
  • Excluded 'AsBuiltReport.Chart' and 'AsBuiltReport.Diagram' from the list of installed report modules in multiple locations to streamline report generation.

…d New-AsBuiltReportConfig scripts

- Updated string comparisons from `""` to `''` for consistency and clarity.
- Enhanced validation logic for user inputs in various prompts to ensure default values are set correctly.
- Excluded 'AsBuiltReport.Chart' and 'AsBuiltReport.Diagram' from the list of installed report modules in multiple locations to streamline report generation.
Copilot AI review requested due to automatic review settings April 4, 2026 18:36
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors interactive input validation and report-module discovery in the New-AsBuiltConfig, New-AsBuiltReport, and New-AsBuiltReportConfig PowerShell entrypoints, while also updating workflow tooling and standardizing quoting.

Changes:

  • Excludes AsBuiltReport.Chart and AsBuiltReport.Diagram from discovered report modules (validation + argument completers).
  • Normalizes string literals to single quotes in multiple scripts and style assets.
  • Bumps the Bluesky release-post GitHub Action version in the release workflow.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AsBuiltReport.Core/Src/Public/New-AsBuiltReportConfig.ps1 Filters module discovery to omit Chart/Diagram and updates quoting in validation/completer logic.
AsBuiltReport.Core/Src/Public/New-AsBuiltReport.ps1 Filters available report modules, normalizes quoting, and adjusts message output code paths.
AsBuiltReport.Core/Src/Public/New-AsBuiltConfig.ps1 Normalizes empty-string checks and defaulting behavior in interactive prompts.
AsBuiltReport.Core/AsBuiltReport.Core.Style.ps1 Switches embedded Base64 image string to single-quoted literal.
.github/workflows/Release.yml Updates zentered/bluesky-post-action from v0.3.0 to v0.4.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

# If StyleFilePath was specified, ensure the file provided in the path exists, otherwise exit with error
# If StyleFilePath was specified, ensure the file provided in the path exists, otherwise exit with error'AsBuiltReport.Core'
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment has an unexpected trailing string ("'AsBuiltReport.Core'") which looks like an accidental paste and makes the guidance confusing. Please remove the stray text so the comment reads cleanly.

Suggested change
# If StyleFilePath was specified, ensure the file provided in the path exists, otherwise exit with error'AsBuiltReport.Core'
# If StyleFilePath was specified, ensure the file provided in the path exists, otherwise exit with error

Copilot uses AI. Check for mistakes.
#region Generate PScribo document
# if Verbose has been passed
if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) {
if ($PSCmdlet.MyInvocation.BoundParameters['Verbose'].IsPresent) {
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$PSCmdlet.MyInvocation.BoundParameters['Verbose'] is $null when -Verbose isn’t supplied, so accessing .IsPresent can throw "You cannot call a method on a null-valued expression" and prevent the non-verbose branch from running. Use a null-safe check like $PSBoundParameters.ContainsKey('Verbose') (or equivalent) before deciding which path to take.

Suggested change
if ($PSCmdlet.MyInvocation.BoundParameters['Verbose'].IsPresent) {
if ($PSBoundParameters.ContainsKey('Verbose')) {

Copilot uses AI. Check for mistakes.
# Find the root folder where the module is located for the report that has been specified
try {
$Module = Get-Module -Name "AsBuiltReport.$Report" -ListAvailable | Where-Object { $_.name -ne 'AsBuiltReport.Core' } | Sort-Object -Property Version -Descending | Select-Object -Unique
$Module = Get-Module -Name "AsBuiltReport.$Report" -ListAvailable | Where-Object { $_.name -ne 'AsBuiltReport.Core' -and $_.name -ne 'AsBuiltReport.Chart' -and $_.name -ne 'AsBuiltReport.Diagram' } | Sort-Object -Property Version -Descending | Select-Object -Unique
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Get-Module ... | Sort-Object Version -Descending | Select-Object -Unique can still return multiple module versions (because different versions are distinct objects), which makes $Module an array. That can lead to incorrect path building / truthy array behavior in if (Test-Path ...) and confusing output. Prefer selecting a single module (e.g., take the first after sorting) to ensure $Module.ModuleBase and $Module.Name are scalars.

Suggested change
$Module = Get-Module -Name "AsBuiltReport.$Report" -ListAvailable | Where-Object { $_.name -ne 'AsBuiltReport.Core' -and $_.name -ne 'AsBuiltReport.Chart' -and $_.name -ne 'AsBuiltReport.Diagram' } | Sort-Object -Property Version -Descending | Select-Object -Unique
$Module = Get-Module -Name "AsBuiltReport.$Report" -ListAvailable | Where-Object { $_.name -ne 'AsBuiltReport.Core' -and $_.name -ne 'AsBuiltReport.Chart' -and $_.name -ne 'AsBuiltReport.Diagram' } | Sort-Object -Property Version -Descending | Select-Object -First 1

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants