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

fix(shopify): Get the next URL in pagination instead of previous one #12902

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kodaho
Copy link

@kodaho kodaho commented Jan 28, 2025

Summary

Shopify pagination in the REST API is handled by providing the next page URL in the link HTTP header. The next URL should be parsed from a string with the following format.

<https://shop.myshopify.com/admin/api/2024-07/products.json?limit=10&page_info=xxx>; rel="next"

The formula used to retrieve the URL was url.split('; ')[0].replace(...), which is OK in the above example.
The issue is that starting page 2, the header contains several links (a previous and a next one), with the following format:

<https://shop.myshopify.com/admin/api/2024-07/products.json?limit=10&page_info=xxx>; rel="previous", <https://shop.myshopify.com/admin/api/2024-07/products.json?limit=10&page_info=xxx>; rel="next"

With such value and by using the previous formula, the previous URL is retrieved instead of the next one, creating an infinite loop: on page 2, the next request will fetch information from page 1, then retrieve the next URL of page 2, only to re-return on page 1.

The proposed fix is to split the link header with , and filter on the links containing "next", and only after that, apply the formula.

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@CLAassistant
Copy link

CLAassistant commented Jan 28, 2025

CLA assistant check
All committers have signed the CLA.

@kodaho kodaho changed the title fix(shopify): get the next URL in pagination instead of previous one fix(shopify): Get the next URL in pagination instead of previous one Jan 28, 2025
@n8n-assistant n8n-assistant bot added community Authored by a community member node/improvement New feature or request in linear Issue or PR has been created in Linear for internal review labels Jan 28, 2025
@Joffcom
Copy link
Member

Joffcom commented Jan 28, 2025

Hey @kodaho,

Thanks for the PR, We have created "GHC-643" as the internal reference to get this reviewed.

One of us will be in touch if there are any changes needed, in most cases this is normally within a couple of weeks but it depends on the current workload of the team.

@kodaho
Copy link
Author

kodaho commented Jan 28, 2025

Hi @Joffcom, thank you for the quick response and the information!

Since the workflows I’m working on rely on the Shopify nodes, I’ll explore whether there are alternative nodes that can provide the data I need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member in linear Issue or PR has been created in Linear for internal review node/improvement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants