Skip to content

failure in download file via invoke-restmethod or invoke-webrequest is suppressed and results in partial file download #17931

Closed

Description

@AAATechGuy

Prerequisites

Steps to reproduce

For context,

See detailed analysis here: #17896 (comment)

See Ilya (@iSazonov) 's comment #17896 (comment)

It is not easy to get an exception from the copy task. I disconnected network for ~1 minutes and restore it. Original cmdlet waits some seconds and silently stop with semi-downloaded file. With the change (without catching AggregateException) user get follow error:
image
I think it is right behavior and we should remove the regression.

Expected behavior

Throw an exception if download fails.

Actual behavior

Does not throw an exception if download fails.

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


### Visuals

_No response_

Activity

  1. added
    Needs-Triage
    on Aug 18, 2022
  2. ghost added
    In-PR
    on Aug 18, 2022
  3. ghost removed
    In-PR
    on Aug 23, 2022
  4. ghost added
    Resolution-Fixed
    on Aug 23, 2022
  5. ghost removed
    Needs-Triage
    on Aug 23, 2022
  6. ahmad-beshr commented on Sep 19, 2022

    @ahmad-beshr

    I have the same behavior. The downloaded file is too small compared to the actual file. Is there any resolution for this?
    This is what I am using:
    Invoke-RestMethod -Uri $arm_file_uri -Method Get -ContentType "application/Json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} | Out-File $server_file_Path -Force

  7. iSazonov commented on Sep 19, 2022

    @iSazonov
    Collaborator

    ahmad-beshr You should use latest daily build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-Fixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions