Add namespace validation when accessing add-on purchase URLs without a linked namespace

Problem

if the customer has a subscription which is not linked to a namespace and then manually enters the URL to purchase compute minutes / storage (like - /subscriptions/new?plan_id=2c92a0086a07f4a8016a2c0a1f7b4b4c&subscription_id=<subscription-name>&transaction=ci_minutes), it will not redirect but rather open the flow and give an error. This seems to be happening because in the redirection logic we just check for subscription presence and not presence of subscription.gitlab_namespace. However, we return the namespace to the frontend only if subscription.gitlab_namespace is present. Hence, in this case the flow will not be redirected and neither will it send the namespace details to the frontend (since there is no namespace attached to subscription) and the flow will break (since frontend needs namespace details to send back in the API request).

Proposal

Check this thread for details.

Option 1: Add an additional check to eligible_to_buy_ci_minutes? & eligible_to_buy_storage? to check for a linked namespace to the subscription.

Option 2: Use retrieve_current_namespace method for the redirection logic as proposed here so that the logic to send namespace details to the frontend and redirect customer in case of missing namespace details is in sync.

For messaging we can use the generic messaging that is already being used as mentioned here.

Handle this with the generic messaging that we discussed here i.e. - "The purchase cannot be completed because the link appears to be invalid. Please refer to the documentation for guidance on how to proceed." So for any invalid URL through which the customer tries to land on the purchase compute minutes / purchase storage flow, we show the above message which points them to the documentation to purchase the respective add-on

Edited May 07, 2025 by Sharmad Nachnolkar
Assignee Loading
Time tracking Loading