fix: handle PS 8.x {"products":false} response in getProductByReference
PS 8.2.5 returns {"products": false} instead of {"products": []}
when a reference filter finds no matching products. Jackson cannot
deserialize false as a List, throwing HttpMessageConversionException.
Catch it and return Optional.empty() so pushProduct takes the CREATE
path correctly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9fd11219af
commit
ca7948d6e6
|
|
@ -6,6 +6,7 @@ import com.teterialosjuanjos.tfg.sync_service.integration.prestashop.exception.P
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConversionException;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
|
|
@ -87,6 +88,10 @@ public class PrestashopClient {
|
|||
// PS may return 404 instead of 200+empty when filter finds no results
|
||||
if (e.getStatusCode() != null && e.getStatusCode().value() == 404) return Optional.empty();
|
||||
throw e;
|
||||
} catch (HttpMessageConversionException e) {
|
||||
// PS 8.x returns {"products": false} instead of {"products": []} when filter has no results
|
||||
log.debug("PS returned unparseable body for reference filter={}, treating as not found", reference);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue