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

Error on creating SubscriptionItemPriceDataRecurring #66

Closed
raulsi opened this issue Jun 28, 2021 · 6 comments · Fixed by #94
Closed

Error on creating SubscriptionItemPriceDataRecurring #66

raulsi opened this issue Jun 28, 2021 · 6 comments · Fixed by #94

Comments

@raulsi
Copy link
Contributor

raulsi commented Jun 28, 2021

Struct PlanInterval exist multiple places which is causing issue when creating the subscription with a inline price plan:

let recurring: stripe::SubscriptionItemPriceDataRecurring = stripe::SubscriptionItemPriceDataRecurring {
      interval: stripe::PlanInterval::Month,
      interval_count: Some(100),
};

this Gives Error :

 interval: stripe::PlanInterval::Month,
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum 'stripe::resources::generated::billing::subscription::PlanInterval', found enum 'PlanInterval'    

I tried removing the extra struct in file subscriptions.rs and subscription_item.rs and import on top it's working this way.

Let me know if there is better way. (Will submit the PR with this changes)

@arlyon
Copy link
Owner

arlyon commented Jun 28, 2021

We cannot manually remove code from generated files as they will be overwritten next time the changes are reapplied from stripe. In any case, I think keeping these seperate is better as we can't guarantee that the 3 data structures will remain identical forever and may break in subtle (breaking) ways in the future.

The only solution is to make sure you use subscription::PlanInterval for subscriptions and the other ones in the other cases.

use stripe::resources::generated::billing::subscription::PlanInterval;

let recurring: stripe::SubscriptionItemPriceDataRecurring = stripe::SubscriptionItemPriceDataRecurring {
-     interval: stripe::PlanInterval::Month,
+     interval: PlanInterval::Month,
      interval_count: Some(100),
};

@arlyon arlyon added the wontfix This will not be worked on label Jun 28, 2021
@raulsi
Copy link
Contributor Author

raulsi commented Jun 30, 2021

@arlyon yes but the problem is another. can't import this module directly.

is there any way to fix this or we have to change the resource to public ?

image

@arlyon
Copy link
Owner

arlyon commented Jul 4, 2021

Yes, sorry, my bad. I understand the problem now. The issue lies with rust and how it handles wildcard exports. The default behaviour is to ignore any clashing names which is why only the first is exported. The solution to this problem in nontrivial, and I wonder if these is a clippy lint that can warn about this in the future. I can imagine a whole host of bugs that could arise from this behavious (rather than opting for a compiler error) and I'm surprised this is the case. Let me have a look at this and get back to you.

Thanks for the report (and patience!).

@arlyon
Copy link
Owner

arlyon commented Oct 8, 2021

I sorted this out by manually untangling the exports and reexporting the structs with relevant names. Will merge once CI passes.

@raulsi
Copy link
Contributor Author

raulsi commented Oct 8, 2021

@arlyon great thanks

@arlyon arlyon closed this as completed in #94 Oct 8, 2021
@raulsi
Copy link
Contributor Author

raulsi commented Oct 27, 2021

@arlyon maybe need to add this #104 also ?

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

Successfully merging a pull request may close this issue.

2 participants