Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cart input shouldn't be taken into account for calculation of instruction usage #3109

Closed
2 tasks done
Hahlh opened this issue Nov 15, 2023 · 1 comment
Closed
2 tasks done
Labels
Area: Functions issues with functions Type: Bug Something isn't working

Comments

@Hahlh
Copy link

Hahlh commented Nov 15, 2023

Please confirm that you have:

  • Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

Function

Expected behavior

The ideal behavior here would be that cart inputs aren't taken into consideration for enforcing function execution limitations as long as they aren't custom attributes that have been attached by the developer.

Actual behavior

It's possible to increase the calculated usage of instructions by simply increasing the amount of line items in cart.

This is the function code we used for testing this:

// @ts-check

/**
 * @typedef {import("../generated/api").RunInput} RunInput
 * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult
 */

/**
 * @type {FunctionRunResult}
 */
const NO_CHANGES = {
  operations: []
}

/**
 * @param {RunInput} input
 */
export function run(input) {
  const mergeOperations = []
  const response = mergeOperations.length
    ? { operations: mergeOperations }
    : NO_CHANGES
  return response
}

Result before:

image

Result after doubling the amount of line items in input.json:

image

The ideal behavior here would be that cart inputs aren't taken into consideration for enforcing function execution limitations as long as they aren't custom attributes that have been attached by the developer.

Operating System

Manjaro Linux

Shopify CLI version (check your project's package.json if you're not sure)

3.50.2

Shell

No response

Node version (run node -v if you're not sure)

No response

What language and version are you using in your application?

No response

@Hahlh Hahlh added the Type: Bug Something isn't working label Nov 15, 2023
@Hahlh Hahlh changed the title [Bug]: Cart JSON of input is wrongfully taken into account for calculation of instructions during test run via function runner [Bug]: Cart input shouldn't be taken into account for calculation of instruction usage Nov 15, 2023
@amcaplan amcaplan added the Area: Functions issues with functions label Nov 22, 2023
@nickwesselman
Copy link
Contributor

Hi @Hahlh! Scaling instruction count on cart size is a planned feature which you can track here:

Shopify/function-examples#329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Functions issues with functions Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants