From d33de8bde5b9b8c8171df59a28166f1f3bffbdc0 Mon Sep 17 00:00:00 2001 From: Julien Perrochet Date: Mon, 2 Sep 2024 21:30:42 +0200 Subject: [PATCH] [scd] oir upsert: fail early with Bad request if both a subscription ID and implicit request are specified --- pkg/scd/operational_intents_handler.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/scd/operational_intents_handler.go b/pkg/scd/operational_intents_handler.go index e8e4d6e53..714f14325 100644 --- a/pkg/scd/operational_intents_handler.go +++ b/pkg/scd/operational_intents_handler.go @@ -455,6 +455,17 @@ func validateAndReturnUpsertParams( } } + if params.NewSubscription != nil { + // The spec states that NewSubscription.UssBaseUrl is required and an empty value + // makes no sense, so we will fail if an implicit subscription is requested but the base url is empty + if params.NewSubscription.UssBaseUrl == "" { + return nil, stacktrace.NewError("Missing required USS base url for new subscription (in parameters for implicit subscription)") + } + if params.SubscriptionId != nil { + return nil, stacktrace.NewError("Cannot provide both a Subscription ID and request an implicit subscription") + } + } + // Check if a subscription is required for this request: // OIRs in an accepted state do not need a subscription. if valid.state.RequiresSubscription() &&