Skip to content

Commit

Permalink
[scd] oir upsert: fail early with Bad request if both a subscription …
Browse files Browse the repository at this point in the history
…ID and implicit request are specified
  • Loading branch information
Shastick committed Sep 2, 2024
1 parent 02f8ac9 commit 493c511
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/scd/operational_intents_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,18 @@ 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 an implicit subscription is requested, the Subscription ID cannot be present.
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() &&
Expand Down

0 comments on commit 493c511

Please sign in to comment.