Skip to content

fix: clamp Write-Progress PercentComplete to 100 max#121

Open
mtellin wants to merge 1 commit into
masterfrom
fix/clamp-write-progress-percent
Open

fix: clamp Write-Progress PercentComplete to 100 max#121
mtellin wants to merge 1 commit into
masterfrom
fix/clamp-write-progress-percent

Conversation

@mtellin

@mtellin mtellin commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Wraps all 19 Write-Progress -PercentComplete calculations in [math]::Min(..., 100) to prevent values exceeding the valid 0–100 range
  • Prevents script crash when counter/denominator mismatches produce percentages > 100 (e.g., more backup selections than backup plans)

Closes #79
Closes #81

Test plan

  • Run Get-AWSSizingInfo.ps1 against an account with backup plans that have multiple selections per plan
  • Verify progress bars render without errors
  • Confirm script completes without PercentComplete validation errors

🤖 Generated with Claude Code

Wrap all PercentComplete calculations with [math]::Min(..., 100) to
prevent values exceeding 100 when counter overshoots (e.g. last item
rounding or off-by-one). Applies to all 19 Write-Progress calls across
EC2, S3, RDS, EFS, EKS, FSx, KMS, Backup, and profile/account loops.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mtellin mtellin force-pushed the fix/clamp-write-progress-percent branch from 791e50d to 0493eef Compare June 16, 2026 23:33

@stevenctong stevenctong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review: all 19 Write-Progress PercentComplete calls are correctly clamped with [math]::Min(..., 100). Mechanical change, no logic modifications, no regressions. Existing KMS division-by-zero guard preserved. LGTM.

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.

BUG: The 200 argument is greater than the maximum allowed range of 100 Bug: AWS Script errors from AWS Cloudshell

2 participants