Skip to content

CMR-11242: Adding Toggle for Granule collections Reference validation#2446

Open
eudoroolivares2016 wants to merge 14 commits into
masterfrom
CMR-11242
Open

CMR-11242: Adding Toggle for Granule collections Reference validation#2446
eudoroolivares2016 wants to merge 14 commits into
masterfrom
CMR-11242

Conversation

@eudoroolivares2016

@eudoroolivares2016 eudoroolivares2016 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Overview

What is the objective?

This adds a feature toggle which when set to false will allow ingesting granules even if the references between keywords (namely, projects, platforms, instruments, instrument characterists , and operational modes). Instead, those will be returns as warnings from ingest response

What are the changes?

Major change: Creating the feature toggle in the common as it needed to be used in both ingest and the umm-lib. Threading that up from the validation so that warnings can be propagated down to the end user response.

Minor Changes:
Creating the feature toggle in the common as it needed to be used in both ingest and the umm-lib there were some additional validation which was dead-code that I am removing. The linter picked up a few changes that I allowed it to leave in there namely spacing. Changing imports to just make this more consistent.

What areas of the application does this impact?

Granule ingest and granule validation

Required Checklist

  • New and existing unit and int tests pass locally and remotely
  • clj-kondo has been run locally and all errors in changed files are corrected
  • I have commented my code, particularly in hard-to-understand areas
  • I have made changes to the documentation (if necessary)
  • My changes generate no new warnings

Additional Checklist

  • I have removed unnecessary/dead code and imports in files I have changed
  • I have cleaned up integration tests by doing one or more of the following:
    • migrated any are2 tests to are3 in files I have changed
    • de-duped, consolidated, removed dead int tests
    • transformed applicable int tests into unit tests
    • reduced number of system state resets by updating fixtures. Ex) (use-fixtures :each (ingest/reset-fixture {})) to be :once instead of :each

@codecov-commenter

codecov-commenter commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.54054% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.97%. Comparing base (d304270) to head (73fbae2).

Files with missing lines Patch % Lines
...src/cmr/ingest/services/ingest_service/granule.clj 5.88% 16 Missing ⚠️
ingest-app/src/cmr/ingest/api/core.clj 20.00% 12 Missing ⚠️
...ngest-app/src/cmr/ingest/validation/validation.clj 20.00% 12 Missing ⚠️
...int-test/src/cmr/system_int_test/data2/granule.clj 14.28% 6 Missing ⚠️
ingest-app/src/cmr/ingest/api/granules.clj 28.57% 5 Missing ⚠️
...m-spec-lib/src/cmr/umm_spec/validation/granule.clj 88.57% 4 Missing ⚠️
...r/umm_spec/validation/umm_spec_validation_core.clj 33.33% 4 Missing ⚠️
ingest-app/src/cmr/ingest/api/collections.clj 50.00% 2 Missing ⚠️
...ngest-app/src/cmr/ingest/api/generic_documents.clj 0.00% 1 Missing ⚠️
ingest-app/src/cmr/ingest/api/services.clj 0.00% 1 Missing ⚠️
... and 3 more

❗ There is a different number of reports uploaded between BASE (d304270) and HEAD (73fbae2). Click for more details.

HEAD has 21 uploads less than BASE
Flag BASE (d304270) HEAD (73fbae2)
24 3
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2446       +/-   ##
===========================================
- Coverage   58.20%   28.97%   -29.23%     
===========================================
  Files        1069     1007       -62     
  Lines       74278    70705     -3573     
  Branches     2165     1253      -912     
===========================================
- Hits        43233    20488    -22745     
- Misses      29028    49015    +19987     
+ Partials     2017     1202      -815     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eudoroolivares2016 eudoroolivares2016 changed the title CMR-11242: Adding Toggle for Granule collections validation CMR-11242: Adding Toggle for Granule collections Reference validation Jun 18, 2026
;; Log the successful ingest, with the metadata size in bytes.
(api-core/log-concept-with-metadata-size concept-to-log request-context)
(api-core/generate-ingest-response headers save-granule-result))))
;; (api-core/generate-ingest-response headers save-granule-result)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

remove

Comment on lines -687 to -688
(let [parsed-dif (c/parse-collection all-fields-collection-xml)]
(is (empty? (v/validate-collection parsed-dif))))))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was the only place that c/parse-collection was called so its not actually being used in production

[variable validations-rules]
(validation-errors->path-errors (v/validate validations-rules variable)))

(comment (def foo (validation-errors->path-errors (v/validate vg/granule-validation-warnings g1)))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Remove the remaining rich comments

(v/validate (cons vv/variable-validations additional-validations)
variable))))

(defn validate-variable-warnings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This wasn't being used at all anywhere

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks like it is used in umm-spec-lib/src/cmr/umm_spec/validation but it looks like perhaps that func is not being used anywhere either...

[variable validations-rules]
(validation-errors->path-errors (v/validate validations-rules variable)))

(comment (def foo (validation-errors->path-errors (v/validate vg/granule-validation-warnings g1)))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Remove the remaining rich comments

{:default []
:parser #(map (comp keyword string/trim) (string/split % #","))})

;; TODO we gotta make sure this is set to true before merging

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the default is already true, why would it not be true?

Also this is a reminder to remove this ;; TODO comment before merging

(def ENABLE_UMM_C_VALIDATION_HEADER "cmr-validate-umm-c")
(def TESTING_EXISTING_ERRORS_HEADER "cmr-test-existing-errors")
(def COLLECTION_WARNING_CONTEXT "After translating item to UMM-C the metadata had the following issue(s): ")
(def COLLECTION_ERROR_CONTEXT "After translating item to UMM-C the metadata had the following existing error(s): ")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

will there ever be a 'regular' error context in the future? If so, renaming this to be COLLECTION_EXISTING_ERROR_CONTEXT could be more beneficial

#{"[:TemporalExtents 0 :RangeDateTimes 0] BeginningDateTime [2001-01-01T12:00:00.000Z] must be no later than EndingDateTime [2000-05-11T12:00:00.000Z]"}})

(format-and-contextualize-warnings-existing-errors foo)
) No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

new line please

[cmr.common-app.api.enabled :as common-enabled]
[cmr.common-app.api.launchpad-token-validation :as lt-validation]
[cmr.common.log :refer [info]]
[cmr.common.util :as util]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you make this alphabetical, so move below cmr.common.services.errors

;; (api-core/generate-ingest-response headers save-granule-result)
(api-core/generate-ingest-response headers (util/remove-nil-keys
(api-core/format-and-contextualize-warnings-existing-errors save-granule-result GRANULE_WARNING_CONTEXT nil)
))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fix paranthesis formatting

(vu/has-parent-validator :short-name "Instrument short name")
(v/every instrument-ref-validations)]})
(def ^:private consistency-validations
"Granule-vs-parent-collection consistency validations. Enforced as errors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rename to Granule-vs-parent-collection-consistency-validations or granule-consistency-validations

set-geometries-spatial-representation
{:geometries (v/every sv/spatial-validation)
:orbit (v/when-present sv/spatial-validation)})])
;; The spatial representation has to be set on the geometries before the conversion because

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this the right formatting? I would check all the files you changed to see if the indents are correct

:sensor-refs s-refs
:operation-modes ["Mode1" "Mode2"]})]
(g/map->PlatformRef {:short-name plat-short-name
:instrument-refs [instr-ref]})))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

new line between funcs

:existing-errors (map str ["e1" "e2"])}
"W: " "E: ")]
(is (= ["W: w1;; w2"] (:warnings out)))
(is (= ["E: e1;; e2"] (:existing-errors out)))))) No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

new line at end

["<example>data</example>"]
"<example>data</example>")))

(deftest format-and-contextualize-warnings-existing-errors-test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

when you build, make sure this test is actually executed and you see them in the logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants