Skip to content

DGS-443 Stop reporting every import failure as a large-country timeout - #186

Open
TLabutis wants to merge 1 commit into
DPDBaltics:mainfrom
TLabutis:DGS-443-fix-misleading-large-country-import-error
Open

DGS-443 Stop reporting every import failure as a large-country timeout#186
TLabutis wants to merge 1 commit into
DPDBaltics:mainfrom
TLabutis:DGS-443-fix-misleading-large-country-import-error

Conversation

@TLabutis

@TLabutis TLabutis commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Problem

Two symptoms were reported on the pick-up point import, and they are one bug plus one misdiagnosis.

  1. Importing Lithuanian pick-up points returns HTTP 500.
  2. The UI reports it as "This country has many pick-up points and requires automatic updates. Due to server limitations, large countries cannot be updated through the browser." and hands the merchant a cron command.

Lithuania is not a large country. Config::COUNTRIES_SKIP_OPENING_HOURS lists only PL. The message was wrong, and because it was wrong the merchant ran the suggested cron command and hit the same underlying fatal from the CLI, still with no real error shown anywhere.

The cause is in views/js/admin/import/import_parcels.js:

if (status === 'timeout' || xhr.status === 500 || xhr.status === 504) {
  showCronRequiredModal('php bin/console dpdbaltics:update-parcel-shops --all');
}

Every HTTP 500 - any PHP fatal, any exception - was funnelled into the large-country modal. The server side was already correct: AdminDPDBalticsAjaxController::handleImportError() inspects the message for timeout / execution time / Maximum execution before returning requires_cron, and buildCronRequiredResponse() builds the command with --country=<iso>. Only the client-side fallback path was wrong.

Changes

  • import_parcels.js - only status === 'timeout' and HTTP 504 open the cron modal. HTTP 500 now shows a real error message pointing at the DPD logs page. The other branches are unchanged.
  • import_parcels.js - new buildCronCommand() prints --country=<iso> for the country the merchant actually selected, falling back to --all only when no ISO is available. Previously the fallback path always suggested --all, which updates every country.
  • AdminDPDBalticsImportExportController.php - passes countryIso and a translatable serverErrorMessage to the JS. countryId (a PrestaShop ID) was already there but is not usable for --country.
  • importing-parcels-popup.tpl - the modal now describes a timeout instead of asserting the country is large. Title Update timed out; body explains the connection closed before the update finished and that the CLI has no time limit.
  • CHANGELOG.md - ## [3.3.2] entries.

Still open - not fixed here

The actual LT 500 is Non-static method Unirest\Request::timeout() cannot be called statically. The module ships apimatic/unirest-php 2.3.0, whose Request is static, but a v4 copy wins the autoloader on some setups, and "prepend-autoloader": false in composer.json makes that ordering possible. The static calls live in invertus/dpdbaltics-api (src/Api/ApiRequest.php), not in this repo, so the fix belongs there - either by scoping the vendor namespace or by moving to the instance API. Flipping prepend-autoloader to true would make DPD's Symfony 3.4 win over PrestaShop core's and is not an option.

After this PR that failure is at least reported honestly instead of being disguised as a capacity limit.

Testing

  • node --check views/js/admin/import/import_parcels.js
  • php -l controllers/admin/AdminDPDBalticsImportExportController.php
  • Country::getIsoById() resolves - the controller is in the global namespace, same call pattern as AdminDPDBalticsAjaxController.php:52. Returns false for an unset selector, which falls back to --all.

Manual check on the import page: a forced 500 shows the server error message; a request exceeding the 360s jQuery timeout shows the cron modal with --country=LT.

The parcel shop import error handler treated HTTP 500 the same as a
timeout, so any server-side fatal opened the "Automatic Update Required"
modal claiming the country has too many pick-up points. Merchants then
ran the suggested cron command and hit the same fatal from the CLI, with
no error ever surfacing in the UI.

Only status 'timeout' and HTTP 504 now open that modal; a 500 shows a
real error message pointing at the DPD logs page. The modal copy no
longer asserts the country is large, and the cron command it prints uses
--country=<iso> for the selected country instead of --all, matching what
AdminDPDBalticsAjaxController already returns in cron_command.

The underlying LT import fatal (Unirest\Request called statically) lives
in invertus/dpdbaltics-api and is not addressed here.
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.

1 participant