Skip to content

CMR-11237: Validate Ingest and invoke Metadata Fix Service - #2471

Open
eudoroolivares2016 wants to merge 20 commits into
masterfrom
CMR-11237
Open

CMR-11237: Validate Ingest and invoke Metadata Fix Service#2471
eudoroolivares2016 wants to merge 20 commits into
masterfrom
CMR-11237

Conversation

@eudoroolivares2016

@eudoroolivares2016 eudoroolivares2016 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Overview

What is the objective?

This addresses an issue with the collection metadata that prevents the metadata-fixer service (a KMS module to update collection conceptId keywords on keyword updates) from being fully effective. There are some collections where ingests with the old keywords have to be allowed to ingest so those updates don't get blocked. This is a problem because if the metadata fixer service has updated the collection a subsequent ingest with the flag set to false will just override that. This PR when that condition is met will make a request from CMR to that new KMS service which in turn will ingest a new revision of the collection but, with the correct keyword

What are the changes?

Threading through the coll ingest a new bool for keyword-errors. This denotes cases where this would have caused an ingest error but, of course with the keyword flag in place may be allowed to ingest. After we get a conceptId back from the metadatadb we send that off to the kms fixer service. This is done using asyc/go similar to how we reconcile providers with the cmr-ordering service. That is a fire-and-forget so it won't slow down ingest. In transmit lib I've added a method to send this to the KMS which sits in the CMR load balancer and I'm leaving some rich comments for easily testing the integration Since we can't fully test that end to end locally because KMS isn't spun up by the REPL.

All formating is done just using the lein cljfmt tool. I've split out variable validation just to keep the namespaces from getting longer than needed

What areas of the application does this impact?

Collection ingest amd 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

@eudoroolivares2016 eudoroolivares2016 changed the title Cmr 11237 CMR-11237 Jul 28, 2026
@eudoroolivares2016 eudoroolivares2016 changed the title CMR-11237 CMR-11237: Validate Ingest and invoke Metadata Fix Service Jul 28, 2026
@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 18.67470% with 135 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.91%. Comparing base (1db234b) to head (4dfd803).

Files with missing lines Patch % Lines
.../src/cmr/ingest/validation/variable_validation.clj 9.58% 66 Missing ⚠️
.../cmr/ingest/services/ingest_service/collection.clj 16.00% 21 Missing ⚠️
...ngest-app/src/cmr/ingest/validation/validation.clj 9.09% 20 Missing ⚠️
transmit-lib/src/cmr/transmit/kms.clj 36.00% 15 Missing and 1 partial ⚠️
search-app/src/cmr/search/api/keyword.clj 0.00% 4 Missing ⚠️
...-lib/src/cmr/elastic_utils/search/nested_field.clj 0.00% 3 Missing ⚠️
ingest-app/src/cmr/ingest/api/variables.clj 0.00% 2 Missing ⚠️
...r/umm_spec/validation/umm_spec_validation_core.clj 80.00% 2 Missing ⚠️
...pp-lib/src/cmr/common_app/services/kms_fetcher.clj 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2471      +/-   ##
==========================================
- Coverage   57.93%   57.91%   -0.03%     
==========================================
  Files        1073     1074       +1     
  Lines       74658    74699      +41     
  Branches     2175     2173       -2     
==========================================
+ Hits        43251    43259       +8     
- Misses      29379    29408      +29     
- Partials     2028     2032       +4     

☔ 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 marked this pull request as ready for review July 29, 2026 21:15
Comment thread transmit-lib/src/cmr/transmit/kms.clj Outdated
Comment thread transmit-lib/src/cmr/transmit/config.clj Outdated
Comment thread transmit-lib/src/cmr/transmit/kms.clj Outdated
Comment thread ingest-app/src/cmr/ingest/services/ingest_service/collection.clj Outdated
existing-errors (v/umm-spec-validate-collection
sanitized-collection sanitized-prev-collection validation-options context false)
collection-schema-warnings (v/validate-collection-umm-spec-schema collection validation-options)
;; Return warnings for validation errors on collection without checking if they are

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 an incomplete sentence?

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.

Fixed comment was from main got dropped along the way by mistake

Comment thread ingest-app/src/cmr/ingest/validation/validation.clj Outdated
Comment thread ingest-app/src/cmr/ingest/validation/validation.clj Outdated
Comment thread ingest-app/src/cmr/ingest/validation/validation.clj Outdated
Comment thread ingest-app/test/cmr/ingest/services/ingest_service/collection_test.clj Outdated
Comment thread transmit-lib/src/cmr/transmit/kms.clj Outdated
Comment thread transmit-lib/src/cmr/transmit/ordering.clj
Comment thread transmit-lib/test/cmr/transmit/test/kms.clj Outdated
(e/map->PathErrors
{:path field-path
:errors (mapv (partial v/create-error-message
{:path field-path

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 formatting right?

(c/map->RangeDateTimeType
{:BeginningDateTime begin-date-time
:EndingDateTime end-date-time})))
{:BeginningDateTime begin-date-time

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 formatting right?

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.

concept
validation-options)
(let [{:keys [concept warnings existing-errors has-keyword-error?]}
(validate-and-prepare-collection context conceptvalidation-options)

@zimzoom zimzoom Aug 4, 2026

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.

conceptvalidation-options ? Is this a typo? I don't think this symbol exists. Does this compile? I think you meant to put concept validation-options. Moreso concerned about whether this code was tested since this typo does not look like it compiles

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.

Yea I just updated that a second ago by mistake fixed

Comment thread ingest-app/src/cmr/ingest/services/ingest_service/collection.clj Outdated
[clojure.test :refer :all]
[cmr.ingest.services.ingest-service.collection :as collection]))

(deftest should-notify-kms?-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.

Could consider adding tests that verify more behavior outside should-notify-kms? in isolation. For example verifying that if mdb/save-concept throws then KMS is not notified, that the notification receives the concept ID returned by mdb/save-concept, that no notificaiton occurs when the relevant warnings/errors are absent, etc. I'll DM you an example, up to you if it's worth it

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.

5 participants