Problem/Motivation

When deleting a job in drupal, the page gives the following errors in the log:

Smartling failed to delete a file in Dashboard: JobID11550_en_fr-BE.xml. Error: Guzzle:RequestException: Client error: `POST https://api.smartling.com/files-api/v2/projects/60ab0f659/file/delete` resulted in a `400 Bad Request` response: {"response":{"code":"VALIDATION_ERROR","errors":[{"key":"file.not.found","message":"The file \"JobID11550_en_fr-BE.xml\" (truncated...)

Guzzle:RequestException: Client error: `POST https://api.smartling.com/files-api/v2/projects/60ab0f659/file/delete` resulted in a `400 Bad Request` response: {"response":{"code":"VALIDATION_ERROR","errors":[{"key":"file.not.found","message":"The file \"JobID11550_en_fr-BE.xml\" (truncated...)

Can this be handled more gracefully to the user?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

j_bekaert created an issue. See original summary.

loparev’s picture

Hi @j_bekaert,

When user deletes TMGMT Job the connector tries to delete corresponding file in Smartling and if there is no such file it just prints this `Smartling failed to delete a file in Dashboard` message to the logs. Could you please describe what exactly graceful handling do you expect?

nickolaj made their first commit to this issue’s fork.

nickolaj’s picture

Status: Active » Needs review

Patch handles the `file.not.found` error gracefully during job deletion by logging it as a warning instead of an error, since the desired state (file removed) is already achieved. Other API errors are still logged as errors.

j_bekaert’s picture

Hi @loparev, thanks for this improvement.

I'd like to raise a related but separate concern: the job deletion flow has a performance problem that can cause 504 timeouts on jobs with multiple files/attachments, the larger the job, the more change we get the timeout. In tmgmt_smartling_tmgmt_job_predelete(), all Smartling API calls (audit log + file delete) run synchronously and sequentially within the web request. For each file, that's 2 HTTP POST calls to the Smartling API.

Is it an idea to either queue these so it can be processed in the background or use Drupal batches?
Happy to help work on either approach if there's interest.

  • loparev committed 12732e1d on 8.x-9.x authored by nickolaj
    Issue #3575718: Patch handles the `file.not.found` error gracefull...
    
loparev’s picture

thanks @j_bekaert and @nickolaj, this change is included to 8.x-9.23.

@j_bekaert please open separate ticket since it's another issue. I will take a look.

loparev’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.