Skip to content

Commit

Permalink
[FSTORE-1035][APPEND] Fix NPE when validating FV (#1446)
Browse files Browse the repository at this point in the history
bubriks authored Jan 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 8112cab commit 87638de
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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());
}
}
}

0 comments on commit 87638de

Please sign in to comment.