Skip to content

Commit

Permalink
CMR-10287: Create feature toggle for cmr-validate-keyword default beh…
Browse files Browse the repository at this point in the history
…avior change (#2202)

* add feature toggle
* update documentation to say default is false
  • Loading branch information
jmaeng72 authored Dec 30, 2024
1 parent fe3fde2 commit d59a69e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ingest-app/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 11 additions & 3 deletions ingest-app/src/cmr/ingest/api/collections.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@
[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 [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]
Expand Down
4 changes: 4 additions & 0 deletions ingest-app/src/cmr/ingest/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit d59a69e

Please sign in to comment.