Hi, I’m a new user and I’m developing a Shopify app to give discounts in my store. Everything was working before, but now the function stopped returning the expected result and I’m getting this error:
Function export "cart-lines-discounts-generate-run" failed to execute with error: InvalidOutputError
Here’s my code:
import {
CartInput,
CartLinesDiscountsGenerateRunResult,
ProductDiscountSelectionStrategy,
} from "../generated/api";
export async function cartLinesDiscountsGenerateRun(
input: CartInput
): Promise<CartLinesDiscountsGenerateRunResult> {
console.log("input: ", JSON.stringify(input), null, 2);
return {
operations: [
{
productDiscountsAdd: {
selectionStrategy: ProductDiscountSelectionStrategy.All,
candidates: [
{
message: `PRIME DISCOUNT`,
targets: [
{
cartLine: {
id: "gid://shopify/CartLine/0",
},
},
],
value: {
percentage: {
value: 10,
},
},
},
],
},
},
],
};
}
api_version = "2025-07"
[[extensions]]
name = "t:name"
handle = "discount-function"
type = "function"
uid = "..."
description = "t:description"
[[extensions.targeting]]
target = "cart.lines.discounts.generate.run"
input_query = "src/cart_lines_discounts_generate_run.graphql"
export = "cart-lines-discounts-generate-run"
[extensions.build]
command = ""
path = "dist/function.wasm"
[access_scopes]
scopes = “write_discounts,read_customers”