Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception calling Install-AWSToolsModule with -Cleanup #161

Closed
ralish opened this issue Jun 7, 2020 · 5 comments
Closed

Exception calling Install-AWSToolsModule with -Cleanup #161

ralish opened this issue Jun 7, 2020 · 5 comments
Assignees
Labels

Comments

@ralish
Copy link

ralish commented Jun 7, 2020

Expected Behavior

Invoking Install-AWSToolsModule with the -Cleanup parameter should always work, even if no clean-up needs to be performed, or no AWS.Tools modules have been installed (excluding the Installer).

Current Behavior

In some circumstances invoking Install-AWSToolsModule with the -Cleanup parameter can result in an unhandled exception:

Install-AWSToolsModule -Name S3 -CleanUp -Force -Verbose -Debug
VERBOSE: [Install-AWSToolsModule] ConfirmPreference=High WhatIfPreference=False VerbosePreference=Continue Force=True Name=(S3) RequiredVersion= SkipUpdate=False CleanUp=True
VERBOSE: [Find-AWSToolsModule] ConfirmPreference=High WhatIfPreference=False VerbosePreference=Continue Name=(AWS.Tools.S3)
VERBOSE: [Find-AWSToolsModule] End
VERBOSE: [Install-AWSToolsModule] Installing AWS Tools version 4.0.5.0
VERBOSE: [Install-AWSToolsModule] Searching installed modules
VERBOSE: [Install-AWSToolsModule] Removing already installed modules from the. Final list of modules to install: (AWS.Tools.S3)
VERBOSE: [Install-AWSToolsModule] Create folder for temporary repository C:\Users\<removed>\AppData\Local\Temp\34zf4gxo.qn3
VERBOSE: [Install-AWSToolsModule] Registering temporary repository AWSToolsTemp
VERBOSE: [Install-AWSToolsModule] Downloading modules to temporary repository
VERBOSE: [Install-AWSToolsModule] Downloading modules (AWS.Tools.S3)
VERBOSE: [Install-AWSToolsModule] Downloading module AWS.Tools.S3 to C:\Users\<removed>\AppData\Local\Temp\34zf4gxo.qn3
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue Name=AWS.Tools.S3 Path=C:\Users\<removed>\AppData\Local\Temp\34zf4gxo.qn3\AWS.Tools.S3.4.0.5.0.nupkg
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] Manifest signature correctly validated
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] Found dependency AWS.Tools.Common
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] End
VERBOSE: [Install-AWSToolsModule] Downloading module AWS.Tools.Common to C:\Users\<removed>\AppData\Local\Temp\34zf4gxo.qn3
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue Name=AWS.Tools.Common Path=C:\Users\<removed>\AppData\Local\Temp\34zf4gxo.qn3\AWS.Tools.Common.4.0.5.0.nupkg
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] Manifest signature correctly validated
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] End
VERBOSE: [Install-AWSToolsModule] Installing modules (AWS.Tools.S3)
Installing module AWS.Tools.S3 version 4.0.5.0
VERBOSE: [Install-AWSToolsModule] Modules install complete
VERBOSE: [Install-AWSToolsModule] Unregistering temporary repository AWSToolsTemp
VERBOSE: [Install-AWSToolsModule] Delete repository folder C:\Users\<removed>\AppData\Local\Temp\34zf4gxo.qn3
VERBOSE: [Uninstall-AWSToolsModule] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue Force=False
VERBOSE: [Uninstall-AWSToolsModule] Searching installed modules
The property 'Version' cannot be found on this object. Verify that the property exists.
    + CategoryInfo          : NotSpecified: (:) [Where-Object], PropertyNotFoundException
    + FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.Commands.WhereObjectCommand

This appears to be due to the internal Get-AWSToolsModule function not returning any objects if there are no AWS.Tools modules installed. The function filters out the AWS.Tools.Installer module.

The absence of any returned objects means the subsequent code operates on a null object. While the variable is explicitly typed as a PSModuleInfo array, as no objects are ever returned from the function it's never initialised. The subsequent code attempts to iterate a null object and access non-existent properties on the array members.

Possible Solution

Either explicitly check that the array variable isn't null or ensure it's always initialised.

Steps to Reproduce (for bugs)

On a system which does not have any existing AWS.Tools.* modules installed:

Install-Module -Name AWS.Tools.Installer -Force
Install-AWSToolsModule -Name S3 -Cleanup -Force

Context

Habitually using the -Cleanup parameter in Install-AWSToolsModule invocations as well as various script logic in continuous integration scenarios. Manually checking for the presence of any existing AWS.Tools.* modules (minus the installer itself) should not be required.

Your Environment

  • Affected module: AWS.Tools.Installer
  • Module version as reported by Get-AWSPowerShellVersion: 4.0.5.0
  • Operating System and version as reported by $PSVersionTable.OS: Property not present on PowerShell 5.1 (Windows Server 2016)
  • PowerShell version as reported by $PSVersionTable.PSEdition: Desktop
@ralish
Copy link
Author

ralish commented Jun 7, 2020

On further investigation this issue is actually caused by #162. The broken module installations mean the internal Get-AWSToolsModule never returns any results. However, I'm unsure if fixing #162 would fix all possible cases of this issue. Some additional error handling may make sense to add regardless.

@ashishdhingra
Copy link
Contributor

This should be fixed once fix for #194 is implemented.

@ashishdhingra
Copy link
Contributor

This should be fixed in AWS.Tools.Installer 1.0.2.1

@ThisIsArnab
Copy link

This issue is still present for AWS.Tools.Installer 1.0.2.1. For instance the folder name for EC2 module is missing the 4th revision (last part). It is 4.1.12 instead of 4.1.12.0

@ashishdhingra
Copy link
Contributor

This issue is still present for AWS.Tools.Installer 1.0.2.1. For instance the folder name for EC2 module is missing the 4th revision (last part). It is 4.1.12 instead of 4.1.12.0

@ThisIsArnab This behaviour is sometimes seen on Windows PowerShell 5.0 and we cannot control this behaviour. The issue disappears after certain number of retries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants