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

Delete after list breaks pagination #1030

Closed
tamalsaha opened this issue Feb 18, 2020 · 1 comment
Closed

Delete after list breaks pagination #1030

tamalsaha opened this issue Feb 18, 2020 · 1 comment

Comments

@tamalsaha
Copy link

I was trying to delete all my plans in my test account. But delete after list breaks pagination. I was trying something like

params := &stripe.PlanListParams{}
params.Filters.AddFilter("limit", "", "3")
i := plan.List(params)
for i.Next() {
	p := i.Plan()
	fmt.Println(p.Nickname)

	_, _ = plan.Del(p.ID, nil)
}

I got the following error:

2020/02/18 02:16:39 Requesting GET api.stripe.com/v1/plans

2020/02/18 02:16:40 Request completed in 267.71895ms (retry: 0)
pp_m2m_62
2020/02/18 02:16:40 Requesting DELETE api.stripe.com/v1/plans/plan_Es0EEavJF59tJ5

2020/02/18 02:16:40 Request completed in 228.906872ms (retry: 0)
pp_m2m_61
2020/02/18 02:16:40 Requesting DELETE api.stripe.com/v1/plans/plan_Es0ERuAi4imhun

2020/02/18 02:16:40 Request completed in 225.784525ms (retry: 0)
pp_m2m_60
2020/02/18 02:16:40 Requesting DELETE api.stripe.com/v1/plans/plan_Es0EeIs4ZkH1Ea

2020/02/18 02:16:40 Request completed in 222.105829ms (retry: 0)
2020/02/18 02:16:40 Requesting GET api.stripe.com/v1/plans

2020/02/18 02:16:41 Request completed in 90.02216ms (retry: 0)
2020/02/18 02:16:41 Request error from Stripe (status 400): {"code":"resource_missing","doc_url":"https://stripe.com/docs/error-codes/resource-missing","status":400,"message":"No such plan: plan_Es0EeIs4ZkH1Ea","param":"starting_after","request_id":"req_Oj34AUyXmOvuyn","type":"invalid_request_error"}

@remi-stripe
Copy link
Contributor

@tamalsaha At the moment, this is expected with the way pagination works. If you delete the last element of the list, the next pagination call will try to fetch results after an object that does not exist in your account anymore.

In this situation, what I'd recommend is to first build the list of ids to delete in a separate array and once you've gone through the full list, you can then loop again to delete all those elements.

nadaismail-stripe pushed a commit that referenced this issue Oct 18, 2024
* Interim commit to flip to another branch

* more tweaks towards progress

* Laid groundwork for data mapping side, and finished hiding sync preferences options

* Changed sync_pref_field_visibility to hidden_sync_pref_fields

* Typo on equality check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants