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

Orchestrator webhook JSON to require "address" field #3354

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions discovery/wh_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

type webhookResponse struct {
Address string `json:"address,omitempty"`
Address string `json:"address"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this does much since omitempty only applies on encoding, not decoding, and the JSON parser will happy deserialize an object that has an empty address field

Score float32 `json:"score,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we also make score required?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd leave it as omitempty. Would need to analyze more how it's used and if we always need it.

}

Expand Down Expand Up @@ -147,12 +147,9 @@ func deserializeWebhookJSON(body []byte) ([]common.OrchestratorLocalInfo, error)
}
var infos []common.OrchestratorLocalInfo
for _, addr := range addrs {
if addr.Address == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably want to keep this in for resiliency, since the JSON parser will still deserialize objects with empty addresses (unless ParseRequestURI returns an error on empty inputs; can you confirm that?)

continue
}
uri, err := url.ParseRequestURI(addr.Address)
if err != nil {
glog.Errorf("Unable to parse address %q : %s", addr.Address, err)
glog.Errorf("Unable to parse address %q : %s", addr.Address, err)
continue
}
infos = append(infos, common.OrchestratorLocalInfo{URL: uri, Score: addr.Score})
Expand Down
Loading