geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
430 stars 489 forks source link

Fix error reading array that could be undefined in ows service #8428

Open ianwallen opened 1 month ago

ianwallen commented 1 month ago

Fix error reading array that could be undefined in ows service

Without this fix the following error could be displayed in JavaScript console Cannot read properties of undefined (reading 'length')

Checklist

josegar74 commented 1 month ago

@ianwallen do you have a service that cause the issue and can be used for testing?

ianwallen commented 1 month ago

While I was testing the file uploads for #8427 in our environment which was based on GN 4.2.9 branch, I was seeing the error constantly showing up in the java console. I assumed that it was good practice to add a if (Array.isArray(layers)) { before using the array.
If it should never happen that layers is not an array and it is always defined then we can abandon this PR and I can raise a bug the next time I see the error occur.