Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMR-10287: Create feature toggle for cmr-validate-keyword default behavior change #2202

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this line probably won't be updated again until the feature toggle is removed, I'm wondering if we need to communicate here that work is being done to change it to default true in the various environments. Perhaps a note in parens?
Though I'm not sure how important that is or how quick we'll be getting that work done


**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
Loading