We are getting a random error on AppSubscriptionCreate mutation, as well as with the legacy rest api RecurringApplicationCharge.
Our return url is short (28 characters), yet the api fails randomly with
Validation failed: Return url is too long (maximum is 255 characters)
What’s even more strange is that retrying several times, refreshing the page, etc. does work after a bit of time. I suspect the error is somewhere else, but the support couldn’t help so far.
Anyone got a similar issue ?
try {
const queryResult = await this.runWithThrottling(() =>
this.graphQlClient.request(
`#graphql
mutation AppSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!, $test: Boolean!, $trialDays: Int) {
appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems, test: $test, trialDays: $trialDays) {
userErrors {
field
message
}
appSubscription {
...AppSubscriptionFragment
}
confirmationUrl
}
}
${AppSubscriptionFragment}`,
{
variables: {
name: plan,
returnUrl: config.SERVER_URL.toString(), // very short
lineItems: billing[plan].lineItems.map((item) => {
if (item.interval === "EVERY_30_DAYS") {
return {
plan: {
appRecurringPricingDetails: {
price: {
amount: customMonthlyPrice
? customMonthlyPrice.amount
: item.amount,
currencyCode: customMonthlyPrice
? (customMonthlyPrice.currencyCode as CurrencyCode)
: (item.currencyCode as CurrencyCode),
},
interval: "EVERY_30_DAYS" as AppPricingInterval,
},
},
};
} else {
return {
plan: {
appUsagePricingDetails: {
cappedAmount: {
amount: customMonthlyPrice
? Math.max(
item.amount,
customMonthlyPrice.amount * 10,
)
: item.amount,
currencyCode: customMonthlyPrice
? (customMonthlyPrice.currencyCode as CurrencyCode)
: (item.currencyCode as CurrencyCode),
},
terms: item.terms || "",
},
},
};
}
}),
test: isTest,
trialDays: billing[plan].trialDays,
},
},
),
);
if (!queryResult.data?.appSubscriptionCreate?.confirmationUrl) {
if (queryResult.errors) {
throw queryResult.errors;
} else {
throw new BaseError(
"no errors in query result, but no result either",
{
rawQueryResult: JSON.stringify(queryResult),
},
);
}
}
return queryResult.data?.appSubscriptionCreate?.confirmationUrl;
} catch (e) {
const error = BaseError.wrap(e, {
shopName: this.session.shop,
plan,
isTest,
customMonthlyPrice,
});
logger().error(error);
throw error;
}