[client] Move the MDM precedence into ResolveUploadURL

Three of the four bundle paths ordered the destinations themselves, each with
its own copy of "MDM first, then what was asked for". Give the resolver the MDM
value as its first argument so the order lives in one place and a call site
cannot express a different one.

Pure refactor: the daemon passes "" for now, matching what it does today, and
the remote job and both mobile SDKs resolve exactly as before.
This commit is contained in:
riccardom
2026-09-25 13:34:17 +02:00
parent c3993bef73
commit b3ee6c9af2
6 changed files with 52 additions and 24 deletions
+5 -8
View File
@@ -1479,16 +1479,13 @@ func (e *Engine) handleBundle(params *mgmProto.BundleParameters) (*mgmProto.JobR
log.Warnf("get latest sync response: %v", err)
}
// Resolve the upload destination: an MDM override, when set, takes
// precedence over the job's URL. Both are validated the same way. With
// neither, the destination this deployment publishes is used, and failing
// that the service NetBird runs.
uploadURL := params.GetUploadUrl()
if override := e.config.ProfileConfig.DebugBundleUploadURL; override != "" {
// Resolve the upload destination: the MDM policy, then the job's URL, then
// what this deployment publishes, then the service NetBird runs.
mdmUploadURL := e.config.ProfileConfig.DebugBundleUploadURL
if mdmUploadURL != "" && params.GetUploadUrl() != "" && mdmUploadURL != params.GetUploadUrl() {
log.Infof("using MDM debug bundle upload URL override instead of the management-supplied value")
uploadURL = override
}
uploadURL = debug.ResolveUploadURL(uploadURL, e.DebugUploadURL())
uploadURL := debug.ResolveUploadURL(mdmUploadURL, params.GetUploadUrl(), e.DebugUploadURL())
// Validated after resolution, so the destination this deployment published
// meets the same rule as one named in the job. Management validates it at