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

Conversation

pwilczynskiclearcode
Copy link
Contributor

I can't figure out the situation why we would accept empty address and silently skip it. I think this should be a required field. Also we don't specify default score anywhere on the code or I can't find it

Copy link

linear bot commented Jan 16, 2025

@github-actions github-actions bot added go Pull requests that update Go code docs labels Jan 16, 2025
@@ -16,7 +16,7 @@ import (
)

type webhookResponse struct {
Address string `json:"address,omitempty"`
Address string `json:"address"`
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.

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 33.73050%. Comparing base (8d48192) to head (3dc4b2c).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #3354         +/-   ##
===================================================
+ Coverage   33.72602%   33.73050%   +0.00448%     
===================================================
  Files            141         141                 
  Lines          37434       37432          -2     
===================================================
+ Hits           12625       12626          +1     
+ Misses         24088       24086          -2     
+ Partials         721         720          -1     
Files with missing lines Coverage Δ
discovery/wh_discovery.go 64.00000% <100.00000%> (+2.23529%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d529445...3dc4b2c. Read the comment docs.

Files with missing lines Coverage Δ
discovery/wh_discovery.go 64.00000% <100.00000%> (+2.23529%) ⬆️

@@ -16,7 +16,7 @@ import (
)

type webhookResponse struct {
Address string `json:"address,omitempty"`
Address string `json:"address"`
Score float32 `json:"score,omitempty"`
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.

{"address":"https://10.4.3.2:8935"},
{"address":"https://10.4.4.3:8935"},
{"address":"https://10.4.5.2:8935"}
{"address":"https://10.4.3.2:8935", "score": 1.0},
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think you can keep it without scores. But put to you.

@pwilczynskiclearcode pwilczynskiclearcode force-pushed the ENG-2368-orch-webhook-omitempty branch from 9503cd2 to 8c1deef Compare January 16, 2025 10:42
@pwilczynskiclearcode pwilczynskiclearcode marked this pull request as ready for review January 16, 2025 10:43
@pwilczynskiclearcode pwilczynskiclearcode force-pushed the ENG-2368-orch-webhook-omitempty branch from 8c1deef to 3dc4b2c Compare January 17, 2025 17:07
@@ -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

@@ -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?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants