From 87638de873276c5aa7abbbda020593545b523867 Mon Sep 17 00:00:00 2001 From: Ralf Date: Sat, 6 Jan 2024 19:02:51 +0100 Subject: [PATCH] [FSTORE-1035][APPEND] Fix NPE when validating FV (#1446) --- .../FeatureViewInputValidator.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/featureview/FeatureViewInputValidator.java b/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/featureview/FeatureViewInputValidator.java index a4dc55dfba..6f10372058 100644 --- a/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/featureview/FeatureViewInputValidator.java +++ b/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/featureview/FeatureViewInputValidator.java @@ -47,7 +47,7 @@ public class FeatureViewInputValidator { public void validate(FeatureViewDTO featureViewDTO, Project project, Users user) throws FeaturestoreException { featurestoreInputValidation.verifyUserInput(featureViewDTO); - validateCreationInput(featureViewDTO); + validateCreationInput(featureViewDTO.getQuery()); Query query = queryController.convertQueryDTO(project, user, featureViewDTO.getQuery(), false); validateVersion(featureViewDTO.getVersion()); trainingDatasetInputValidation.validateFeatures(query, featureViewDTO.getFeatures()); @@ -56,21 +56,19 @@ public void validate(FeatureViewDTO featureViewDTO, Project project, Users user) } } - public void validateCreationInput(FeatureViewDTO featureViewDTO) throws FeaturestoreException { - if (featureViewDTO.getQuery() == null) { + public void validateCreationInput(QueryDTO queryDTO) throws FeaturestoreException { + if (queryDTO == null) { throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.FEATURE_VIEW_CREATION_ERROR, Level.FINE, "`Query` is missing from input."); } - validateCreationInput(featureViewDTO.getQuery()); - } - - public void validateCreationInput(QueryDTO queryDTO) throws FeaturestoreException { - if (queryDTO.getLeftFeatures().isEmpty()) { + if (queryDTO.getLeftFeatures() == null || queryDTO.getLeftFeatures().isEmpty()) { throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.FEATURE_VIEW_CREATION_ERROR, Level.FINE, - "Feature View queries must have features"); + "Queries must have features"); } - for (JoinDTO joinDTO : queryDTO.getJoins()) { - validateCreationInput(joinDTO.getQuery()); + if (queryDTO.getJoins() != null) { + for (JoinDTO joinDTO : queryDTO.getJoins()) { + validateCreationInput(joinDTO.getQuery()); + } } }