DDFBRA-283 - Ensure v1/products/
is never called without an identifier
#1597
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to issue
https://reload.atlassian.net/browse/DDFBRA-283
Description
We have identified a recurring issue in the code where attempts are made to access the first element of an empty array (
array[0]
), which results inundefined
.This issue occurs across all articles where the identifier is an empty array.
Additionally, our TypeScript implementation requires the
useGetV1ProductsIdentifier
hook to receive a string. To satisfy TypeScript, we currently use|| ""
, even though the hook is only activated when a value is present. However, this approach has inadvertently allowed errors to occur, and we have been uncertain about how to address this properly.This change ensures that the
|| ""
fallback inuseGetV1ProductsIdentifier
is never activated, effectively preventing the error from occurring.Test
https://varnish.pr-1861.dpl-cms.dplplat01.dpl.reload.dk/search?q=hest
Select "articles" in the facet and make sure no drafts are created for
v1/products/