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

Bug fix: adding body back to response #13701

Merged
merged 5 commits into from Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/armcore/go.mod
Expand Up @@ -3,6 +3,6 @@ module github.com/Azure/azure-sdk-for-go/sdk/armcore
go 1.14

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.1
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.3
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0
)
4 changes: 2 additions & 2 deletions sdk/armcore/go.sum
@@ -1,5 +1,5 @@
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.1 h1:YLBIWApuKB/RS0dK/mk/2g6x2+kjI9djMKqViZDTD88=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.1/go.mod h1:pElNP+u99BvCZD+0jOlhI9OC/NB2IDTOTGZOZH0Qhq8=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.3 h1:Q/fMaKaJfKuwlQNELa2ttHS3zzn0KXf43HmrvAYRxMY=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.3/go.mod h1:pElNP+u99BvCZD+0jOlhI9OC/NB2IDTOTGZOZH0Qhq8=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0 h1:HG1ggl8L3ZkV/Ydanf7lKr5kkhhPGCpWdnr1J6v7cO4=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
12 changes: 12 additions & 0 deletions sdk/armcore/poller.go
Expand Up @@ -6,10 +6,12 @@
package armcore

import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -452,6 +454,16 @@ func (pt *pollingTrackerBase) updateRawBody() error {
pt.Err = err
return pt.Err
}
// seek back to the beginning of the body or reassign the information to the body
if seeker, ok := pt.resp.Body.(io.Seeker); ok {
_, err = seeker.Seek(0, io.SeekStart)
if err != nil {
return err
jhendrixMSFT marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
// put the body back so it's available to other callers
pt.resp.Body = ioutil.NopCloser(bytes.NewReader(b))
}
// observed in 204 responses over HTTP/2.0; the content length is -1 but body is empty
if len(b) == 0 {
return nil
Expand Down
2 changes: 1 addition & 1 deletion sdk/azcore/version.go
Expand Up @@ -10,5 +10,5 @@ const (
UserAgent = "azcore/" + Version

// Version is the semantic version (see http://semver.org) of the pipeline package.
Version = "0.13.0"
Version = "0.13.3"
Copy link
Member

Choose a reason for hiding this comment

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

Since v0.13.3 has already been tagged this won't get picked up.

I've been thinking about this problem in general. At the very minimum, for PRs into master we should have a check to ensure that version.go is being updated and if it isn't to fail CI.

Copy link
Member Author

Choose a reason for hiding this comment

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

The check sounds like a good idea to me. I'll remove this change

Copy link
Member

Choose a reason for hiding this comment

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

In addition, we don't even inject UserAgent into the telemetry string :( I will take a look at fixing this (it's missing for armcore, I haven't checked azidentity).

Copy link
Member Author

Choose a reason for hiding this comment

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

azidentity doesnt do it currently, if I recall correctly.

)