Skip to content

Commit

Permalink
Improve logic for setting registered ad version
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbrophy committed Dec 6, 2024
1 parent 6e31d25 commit 5c65cf3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions director/director.go
Original file line number Diff line number Diff line change
Expand Up @@ -1137,12 +1137,18 @@ func registerServeAd(engineCtx context.Context, ctx *gin.Context, sType server_s
adV2.DisableDirectorTest = true
}

// if we didn't receive a version but we were able to extract the request version from the user agent,
// then we can use the request version as the server version (they should be the same)
// if we didn't receive a version from the ad but we were able to extract the request version from the user agent,
// then we can fallback to the request version
// otherwise, we set the version to unknown because our sources of truth are not available
if adV2.Version == "" && reqVer != nil {
adV2.Version = reqVer.String()
} else {
} else if adV2.Version != "" && reqVer != nil {
_, err := version.NewVersion(adV2.Version)
if err != nil {
// ad version was not a valid version, so we fallback to the request version
adV2.Version = reqVer.String()
}
} else if adV2.Version == "" {
adV2.Version = "unknown"
}

Expand Down

0 comments on commit 5c65cf3

Please sign in to comment.