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

When polling, raise if an error is returned #142

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

geeosh
Copy link
Contributor

@geeosh geeosh commented Nov 28, 2023

Previously, if an error from the API was returned while polling for updates on a file, it would continue polling. I updated the gem so that it raises a RequestError if the API returns an error status. If not, it raises a RetryError, which is swallowed by the retry gem's with_retries block.

Reproduction Steps

  1. Call Uploadcare::Uploader.upload(file_url) with a file type that Uploadcare says isn't supported (oddly the mimetype on a file I get this message with is audio/mpeg, which should be supported).
  2. There will be no output from the console while the gem continues to poll from_url/status/, which returns an error, such as:
{"status":"error","error":"File validation error: Uploading of these file types is not allowed.","error_code":"DownloadFileValidationFailedError"}

@geeosh geeosh force-pushed the fix-polling-failures branch from 83a650d to 6be271f Compare November 28, 2023 13:25
Previously, if an error from the API was returned while polling for updates on a file, it would continue polling. I updated it so that it raises a RequestError if the API returns an error status. If not, it raises a RetryError, which is swallowed by the retry gem's `with_retries` block.

Example of an error that led to continued polling:

```
{"status":"error","error":"File validation error: Uploading of these file types is not allowed.","error_code":"DownloadFileValidationFailedError"}
```
@geeosh geeosh force-pushed the fix-polling-failures branch from 6be271f to 7e55193 Compare November 28, 2023 13:31
@rsedykh rsedykh requested a review from kraft001 November 28, 2023 14:12
@kraft001
Copy link
Collaborator

Hey, @geeosh !
Thank you for the contribution, the update looks great to me!
It would be nice to add a spec to test the new feature

@kraft001 kraft001 changed the base branch from main to 4.4.0 December 11, 2023 06:22
@kraft001 kraft001 merged commit eb0f520 into uploadcare:4.4.0 Dec 11, 2023
6 checks passed
@geeosh
Copy link
Contributor Author

geeosh commented Dec 11, 2023

@kraft001 sure thing, I can submit an update for this later this week.

vipulnsward added a commit that referenced this pull request Mar 9, 2024
* When polling, raise if an error is returned (#142)

Previously, if an error from the API was returned while polling for updates on a file, it would continue polling. I updated it so that it raises a RequestError if the API returns an error status. If not, it raises a RetryError, which is swallowed by the retry gem's `with_retries` block.

Example of an error that led to continued polling:

```
{"status":"error","error":"File validation error: Uploading of these file types is not allowed.","error_code":"DownloadFileValidationFailedError"}
```

* Sign URL uploads if configured (#139)

Fix namespace for service

Add spec for upload_from_url

Fix requiring of SignatureGenerator and location of tests

* Merge with main and add changelog

* Bump version to 4.4.0

* Apply suggestions from code review

Co-authored-by: Roman Sedykh <[email protected]>

---------

Co-authored-by: Josh Schwartzman <[email protected]>
Co-authored-by: Roman Sedykh <[email protected]>
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 this pull request may close these issues.

2 participants