-
Notifications
You must be signed in to change notification settings - Fork 552
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
Stripe::InvalidRequestError when trying to create Stripe File #761
Comments
@AlexanderFisenko I'm assuming you have a |
@ob-stripe yes |
@AlexanderFisenko Okay. Can you double-check that |
@ob-stripe done. It is. |
🤔 Okay. Unfortunately I have no easy way of checking what's happening server-side (since many files contain sensitive information, we do not log the bodies of file creation requests). Is this an actual identity document file, or a placeholder? If it's just a test file with no sensitive information, mind sharing the URL here so I can try to reproduce the issue? |
Thanks! I was able to reproduce the issue. Looks like the library is not sending the actual file contents in the request:
After investigating, it looks like our strategy for detecting @brandur-stripe I think we can relax the check and simply check if the provided object responds to |
Nice find @ob-stripe! I can't think of any reason that we can't just reduce it to I'm on run, so I can take if you like it, but feel free to go for it if you were already doing it and I can take review/release. |
@brandur-stripe Yep, would be great if you could take it (happy to review). I also wonder if we should throw an explicit error if the |
When uploading a file, we previously made a check on whether it supported both `#read` and `#path` before wrapping it in a `Faraday::UploadIO` and sending it off. The second check on `#path` isn't strictly necessary, and as reported in #761 can prevent objects created by `open-uri` from being compatible with file upload. Here we remove the check `#path` so that we just require that objects support `#read`, and in addition error when an object is passed that's not file-compatible and not a string. This should prevent users from seeing the very confusing "Invalid hash" error in these situations. Fixes #761.
@ob-stripe Good call. Took a shot at this in #766. |
When uploading a file, we previously made a check on whether it supported both `#read` and `#path` before wrapping it in a `Faraday::UploadIO` and sending it off. The second check on `#path` isn't strictly necessary, and as reported in #761 can prevent objects created by `open-uri` from being compatible with file upload. Here we remove the check `#path` so that we just require that objects support `#read`, and in addition error when an object is passed that's not file-compatible and not a string. This should prevent users from seeing the very confusing "Invalid hash" error in these situations. Fixes #761.
4.13.0 should contain the fix you need. (And thanks Olivier for diagnosing the problem!) |
@brandur-stripe @oliver-stripe thanks guys! |
Output:
Ruby version: 2.6.1
Rails version: 5.2.2
Stripe version: 4.9
The text was updated successfully, but these errors were encountered: