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 (#1097)
  • Loading branch information
Shastick authored Sep 3, 2024
1 parent 7029a60 commit 074d12c
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 @@ -444,6 +444,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 074d12c

Please sign in to comment.