From 8f8aeab690293a4ffdc0c7516ec6b501a85fe42e Mon Sep 17 00:00:00 2001 From: jmaeng72 <44305062+jmaeng72@users.noreply.github.com> Date: Thu, 19 Dec 2024 11:54:01 -0500 Subject: [PATCH 1/3] add feature toggle --- ingest-app/src/cmr/ingest/api/collections.clj | 15 ++++++++++++--- ingest-app/src/cmr/ingest/config.clj | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ingest-app/src/cmr/ingest/api/collections.clj b/ingest-app/src/cmr/ingest/api/collections.clj index f1cab60af3..e4e0a75bd3 100644 --- a/ingest-app/src/cmr/ingest/api/collections.clj +++ b/ingest-app/src/cmr/ingest/api/collections.clj @@ -7,18 +7,27 @@ [cmr.common.log :refer [info]] [cmr.common.util :as util] [cmr.ingest.api.core :as api-core] + [cmr.ingest.config :as ingest-config] [cmr.ingest.services.ingest-service :as ingest])) (def VALIDATE_KEYWORDS_HEADER "cmr-validate-keywords") (def ENABLE_UMM_C_VALIDATION_HEADER "cmr-validate-umm-c") (def TESTING_EXISTING_ERRORS_HEADER "cmr-test-existing-errors") +(def validate-keywords-default-true-enabled? + "Checks to see if the feature toggle for validate-keywords-default-true is enabled." + (ingest-config/validate-keywords-default-true-enabled)) + (defn get-validation-options "Returns a map of validation options with boolean values" [headers] - {:validate-keywords? (if (= "false" (get headers VALIDATE_KEYWORDS_HEADER)) false true) - :validate-umm? (= "true" (get headers ENABLE_UMM_C_VALIDATION_HEADER)) - :test-existing-errors? (= "true" (get headers TESTING_EXISTING_ERRORS_HEADER))}) + (let [_ (println "validate-keywords-default-true-enabled = " validate-keywords-default-true-enabled?) + validate-keywords-value (if validate-keywords-default-true-enabled? + (if (= "false" (get headers VALIDATE_KEYWORDS_HEADER)) false true) + (= "true" (get headers VALIDATE_KEYWORDS_HEADER)))] + {:validate-keywords? validate-keywords-value + :validate-umm? (= "true" (get headers ENABLE_UMM_C_VALIDATION_HEADER)) + :test-existing-errors? (= "true" (get headers TESTING_EXISTING_ERRORS_HEADER))})) (defn validate-collection [provider-id native-id request] diff --git a/ingest-app/src/cmr/ingest/config.clj b/ingest-app/src/cmr/ingest/config.clj index 632e1cd795..471c8f42cb 100644 --- a/ingest-app/src/cmr/ingest/config.clj +++ b/ingest-app/src/cmr/ingest/config.clj @@ -7,6 +7,10 @@ [cmr.oracle.config :as oracle-config] [cmr.oracle.connection :as conn])) +(defconfig validate-keywords-default-true-enabled + "Flag for whether or not cmr-validate-keywords value is defaulted to true or false in backend when missing in ingest api headers" + {:default true :type Boolean}) + (defconfig progressive-update-enabled "Flag for whether or not collection progressive update is enabled." {:default true :type Boolean}) From e3f33500bc8351355d966e3a4389d5a58fb9d6d6 Mon Sep 17 00:00:00 2001 From: jmaeng72 <44305062+jmaeng72@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:48:53 -0500 Subject: [PATCH 2/3] prettify --- ingest-app/src/cmr/ingest/api/collections.clj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ingest-app/src/cmr/ingest/api/collections.clj b/ingest-app/src/cmr/ingest/api/collections.clj index e4e0a75bd3..3e2715babf 100644 --- a/ingest-app/src/cmr/ingest/api/collections.clj +++ b/ingest-app/src/cmr/ingest/api/collections.clj @@ -21,8 +21,7 @@ (defn get-validation-options "Returns a map of validation options with boolean values" [headers] - (let [_ (println "validate-keywords-default-true-enabled = " validate-keywords-default-true-enabled?) - validate-keywords-value (if validate-keywords-default-true-enabled? + (let [validate-keywords-value (if validate-keywords-default-true-enabled? (if (= "false" (get headers VALIDATE_KEYWORDS_HEADER)) false true) (= "true" (get headers VALIDATE_KEYWORDS_HEADER)))] {:validate-keywords? validate-keywords-value From 1e7326297057e38551e99f9c67dddcb809596be4 Mon Sep 17 00:00:00 2001 From: jmaeng72 <44305062+jmaeng72@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:00:34 -0500 Subject: [PATCH 3/3] update documentation to say default is false --- ingest-app/docs/api.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ingest-app/docs/api.md b/ingest-app/docs/api.md index 4bdaa549bf..a7272c825f 100644 --- a/ingest-app/docs/api.md +++ b/ingest-app/docs/api.md @@ -159,8 +159,10 @@ The following fields are validated: * [Data Format](https://gcmd.earthdata.nasa.gov/kms/concepts/concept_scheme/dataformat?format=csv) - Archival and Distribution File Format, and GetData Format * [ProcessingLevel] (https://gcmd.earthdata.nasa.gov/kms/concepts/concept_scheme/productlevelid?format=csv) - productlevelid -**Note**: cmr-validate-keywords is set to TRUE by default +**Note**: if cmr-validate-keywords header is not set explicitly, it will behave as if it was set to FALSE by default behind the scenes + **Note**: that when multiple fields are present the combination of keywords are validated to match a known combination. + **Note**: Among the validation fields above, [Platforms], [Instruments], [Projects], [Science Keywords], [Location Keywords] and [Data Centers] are also validated when the `Cmr-Validate-Keywords` header is not set to `true` except that validation errors will be returned to users as warnings. **Note**: the following fields are always checked: