GeoServer returns a “500” error and logs a org.geoserver.catalog.ValidationException exception when using the REST API to create a feature type that defines a custom name for a field.
The exception logged is:
org.geoserver.catalog.ValidationException: The CQL source expression for attribute <custom name> refers to attributes unavailable in the data source: [<custom name>]
at org.geoserver.catalog.impl.FeatureTypeValidator.validate(FeatureTypeValidator.java:90) ~[gs-main-2.21-SNAPSHOT.jar:2.21-SNAPSHOT]
at org.geoserver.catalog.impl.FeatureTypeValidator.validate(FeatureTypeValidator.java:48) ~[gs-main-2.21-SNAPSHOT.jar:2.21-SNAPSHOT]
at org.geoserver.catalog.impl.CatalogImpl.validate(CatalogImpl.java:515) ~[gs-main-2.21-SNAPSHOT.jar:2.21-SNAPSHOT]
at org.geoserver.security.SecureCatalogImpl.validate(SecureCatalogImpl.java:1320) ~[gs-main-2.21-SNAPSHOT.jar:2.21-SNAPSHOT]
at org.geoserver.catalog.impl.AbstractFilteredCatalog.validate(AbstractFilteredCatalog.java:633) ~[gs-main-2.21-SNAPSHOT.jar:2.21-SNAPSHOT]
at org.geoserver.catalog.impl.AbstractCatalogDecorator.validate(AbstractCatalogDecorator.java:274) ~[gs-main-2.21-SNAPSHOT.jar:2.21-SNAPSHOT]
at org.geoserver.rest.catalog.FeatureTypeController.featureTypePost(FeatureTypeController.java:281) ~[gs-restconfig-2.21-SNAPSHOT.jar:2.21-SNAPSHOT]
Steps to reproduce the issue:
#. build and run geoserver 2.21.x with elasticsearch extension
#. from web UI, create workspace
#. from web UI, create elasticsearch datastore in workspace
#. from web UI, create a layer from the elasticsearch datastore and specify a custom name for at least one field that differs from the actual field name
#. export feature type from REST API - GET /rest/workspaces/<workspace>/featuretypes/<featuretype>
#. delete layer
#. create identical feature type from exported file - POST /rest/workspaces/<workspace>/datastores/<datastore>/featuretypes
The error can be reproduced without first creating and the layer in the web UI, and skipping right to the POST of the feature type, but this method is both an easy way to construct a valid feature type document, and demonstrates that a valid layer produces the exception.
|