NASA-PDS / validate

Validates PDS4 product labels, data and PDS3 Volumes
https://nasa-pds.github.io/validate/
Apache License 2.0
15 stars 11 forks source link

Confusing error message when running with multiple IM's in local schematron #958

Open rgdeen opened 1 month ago

rgdeen commented 1 month ago

Checked for duplicates

No - I haven't checked

🐛 Describe the bug

Running with local xsd/sch files, somehow we ended up with two versions of PDS4_MSN: PDS4_MSN_1G00_1300 and PDS4_MSN_1M00_1303.

This is clearly an error, but the error message was unhelpful and it took a couple hours to figure out the problem.

[rgd@pdsimg-int1 zz]$ /mnt/pdsdata/scratch/rgd/msam2/validate-3.5.1/bin/validate NLF_0770_0735308162_662FDR_N0390650NCAM03770_0A0195J01.xml -x ldds/*.xsd -S ldds/*.sch

PDS Validate Tool Report

Configuration:
   Version     3.5.1
   Date        2024-07-10T20:20:35Z

Parameters:
   Targets                        [file:/tmp/zz/NLF_0770_0735308162_662FDR_N0390650NCAM03770_0A0195J01.xml]
   User Specified Schemas         [file:/tmp/zz/ldds/PDS4_CART_1G00_1970.xsd, file:/tmp/zz/ldds/PDS4_DISP_1G00_1500.xsd, file:/tmp/zz/ldds/PDS4_GEOM_1G00_1960.xsd, file:/tmp/zz/ldds/PDS4_IMG_1G00_1870.xsd, file:/tmp/zz/ldds/PDS4_IMG_SURFACE_1G00_1280.xsd, file:/tmp/zz/ldds/PDS4_MARS2020_1G00_1010.xsd, file:/tmp/zz/ldds/PDS4_MSN_1G00_1300.xsd, file:/tmp/zz/ldds/PDS4_MSN_1M00_1303.xsd, file:/tmp/zz/ldds/PDS4_MSN_SURFACE_1G00_1220.xsd, file:/tmp/zz/ldds/PDS4_MSSS_CAM_MH_1G00_1030.xsd, file:/tmp/zz/ldds/PDS4_PDS_1G00.xsd, file:/tmp/zz/ldds/PDS4_PROC_1G00_1210.xsd]
   User Specified Schematrons     [file:/tmp/zz/ldds/PDS4_CART_1G00_1970.sch, file:/tmp/zz/ldds/PDS4_DISP_1G00_1500.sch, file:/tmp/zz/ldds/PDS4_GEOM_1G00_1960.sch, file:/tmp/zz/ldds/PDS4_IMG_1G00_1870.sch, file:/tmp/zz/ldds/PDS4_IMG_SURFACE_1G00_1280.sch, file:/tmp/zz/ldds/PDS4_MARS2020_1G00_1010.sch, file:/tmp/zz/ldds/PDS4_MSN_1G00_1300.sch, file:/tmp/zz/ldds/PDS4_MSN_1M00_1303.sch, file:/tmp/zz/ldds/PDS4_MSN_SURFACE_1G00_1220.sch, file:/tmp/zz/ldds/PDS4_MSSS_CAM_MH_1G00_1030.sch, file:/tmp/zz/ldds/PDS4_PDS_1G00.sch, file:/tmp/zz/ldds/PDS4_PROC_1G00_1210.sch]
   Severity Level                 WARNING
   Recurse Directories            true
   File Filters Used              [*.xml, *.XML]
   Data Content Validation        on
   Product Level Validation       on
   Max Errors                     100000
   Registered Contexts File       /mnt/pdsdata/scratch/rgd/msam2/validate-3.5.1/resources/registered_context_products.json

Error near {...rs2020:Observation_Informat...} at char 97 in xsl:template/@match on line 209 column 34 
  XPST0081: Namespace prefix 'mars2020' has not been declared
Error near {...t_clock_partition) or} at char 41 in xsl:when/@test on line 214 column 279 
  XPST0081: Namespace prefix 'mars2020' has not been declared

Product Level Validation Results

  FAIL: file:/tmp/zz/ldds/PDS4_MSN_1M00_1303.sch
      FATAL_ERROR  [error.label.schematron]   Error occurred while processing schematron 'file:/tmp/zz/ldds/PDS4_MSN_1M00_1303.sch': net.sf.saxon.s9api.SaxonApiException: Errors were reported during stylesheet compilation
        1 product validation(s) completed

Summary:

  1 product(s)
  1 error(s)
  0 warning(s)

  Product Validation Summary:
    0          product(s) passed
    1          product(s) failed
    0          product(s) skipped
    1          product(s) total

  Referential Integrity Check Summary:
    0          check(s) passed
    0          check(s) failed
    0          check(s) skipped
    0          check(s) total

  Message Types:
    1            error.label.schematron

End of Report
Completed execution in 7597 ms

Notice the "Error near" messages that come out before the product validation, with references to xsl templates that are not visible to the user. And the error "Namespace prefix 'mars2020' has not been declared" is actually wrong... the namespace has been declared.

🕵️ Expected behavior

This situation is clearly a bug and I'm happy with validate failing. But the error message could be a lot more helpful.

📜 To Reproduce

Including a tarball below with sample image and the set of LDDs. Extract it and then:

validate NLF_0770_0735308162_662FDR_N0390650NCAM03770_0A0195J01.xml -x ldds/*.xsd -S ldds/*.sch

🖥 Environment Info

Did the same thing on both linux and Mac

📚 Version of Software Used

did the same thing on both validate 3.4.1 and 3.5.1

🩺 Test Data / Additional context

junk.tar.gz

🦄 Related requirements

🦄 #xyz

⚙️ Engineering Details

No response

🎉 Integration & Test

No response

jordanpadams commented 1 month ago

@rgdeen we got your ticket. we will add it to the backlog.

rgdeen commented 1 month ago

Okay so further investigation... something is wrong with the 1M00 schematron. If I use it alone (even renamed to 1G to match the others), I get the above error. So it's not about having multiple versions... it's about having a bad schematron file.

So validate should somehow at least report which file it's trying to read when this kind of error occurs. It would be okay if it just did this with verbose=1 for debugging purposes (like, maybe even always report "reading schematron xxx" in verbose mode?). The error is referring to mars2020 somehow which has nothing to do with the msn ldd, which is what makes it so hard to find.

I'll submit a ticket on the msn ldd itself.

jordanpadams commented 1 month ago

@rgdeen FYI, I updated your original ticket to format the validate execution to properly document how it was run

jordanpadams commented 1 month ago

@rgdeen looks like this may be an issue with your CLI execution with local schemas/schematrons. It checks out when you load from the internet:

$ ./validate -t ~/Downloads/junk/*.xml --skip-content-validation

PDS Validate Tool Report

Configuration:
   Version     3.5.2
   Date        2024-07-11T16:56:48Z

Parameters:
   Targets                      [file:/Users/jpadams/Downloads/junk/NLF_0770_0735276113_691FDR_N0390000NCAM00501_0A0295J02.xml, file:/Users/jpadams/Downloads/junk/NLF_0770_0735308162_662FDR_N0390650NCAM03770_0A0195J01.xml]
   Severity Level               WARNING
   Recurse Directories          true
   File Filters Used            [*.xml, *.XML]
   Data Content Validation      off
   Product Level Validation     on
   Max Errors                   100000
   Registered Contexts File     /Users/jpadams/test/validate-3.5.2/resources/registered_context_products.json

Product Level Validation Results

  PASS: file:/Users/jpadams/Downloads/junk/NLF_0770_0735276113_691FDR_N0390000NCAM00501_0A0295J02.xml
      WARNING  [warning.label.schema]   The schema version(s) [/PDS4//MSN/V1/PDS4_MSN_1G00_1300] does/do not match the schematron version(s) [/PDS4/MSN/V1/PDS4_MSN_1G00_1300].
      WARNING  [warning.label.context_ref_mismatch]   line 64: Context reference name mismatch. Value: 'Mars2020' Expected one of: '[MARS 2020]'
      WARNING  [warning.label.context_ref_mismatch]   line 74: Context reference name mismatch. Value: 'Mars 2020' Expected one of: '[Perseverance]'
      WARNING  [warning.label.context_ref_mismatch]   line 83: Context reference name mismatch. Value: 'Navigation Camera Left' Expected one of: '[ENGINEERING CAMERA SUITE (ECAM)]'
        1 product validation(s) completed

  PASS: file:/Users/jpadams/Downloads/junk/NLF_0770_0735308162_662FDR_N0390650NCAM03770_0A0195J01.xml
      WARNING  [warning.label.context_ref_mismatch]   line 64: Context reference name mismatch. Value: 'Mars2020' Expected one of: '[MARS 2020]'
      WARNING  [warning.label.context_ref_mismatch]   line 74: Context reference name mismatch. Value: 'Mars 2020' Expected one of: '[Perseverance]'
      WARNING  [warning.label.context_ref_mismatch]   line 83: Context reference name mismatch. Value: 'Navigation Camera Left' Expected one of: '[ENGINEERING CAMERA SUITE (ECAM)]'
        2 product validation(s) completed

Summary:

  2 product(s)
  0 error(s)
  7 warning(s)

  Product Validation Summary:
    2          product(s) passed
    0          product(s) failed
    0          product(s) skipped
    2          product(s) total

  Referential Integrity Check Summary:
    0          check(s) passed
    0          check(s) failed
    0          check(s) skipped
    0          check(s) total

  Message Types:
    6            warning.label.context_ref_mismatch
    1            warning.label.schema

End of Report
Completed execution in 20342 ms