NASA-PDS / validate

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

validate does not work correct when path name contains a space on mac #427

Closed jordanpadams closed 11 months ago

jordanpadams commented 2 years ago

Hi @jordanpadams @qchaupds whilst this resolves the issue for me on linux, @dcoia740 is still facing issues on the Mac - could you confirm if the fix was tested there, and if it works OK? Thanks!

Originally posted by @msbentley in https://github.com/NASA-PDS/validate/issues/381#issuecomment-950731977

When testing a against a file with a space in the path:


PDS Validate Tool Report

Configuration:
   Version                       2.2.0-SNAPSHOT
   Date                          2021-10-25T17:23:12Z

Parameters:
   Targets                       [file:/Users/jpadams/test/validate%20189/validate189.xml]
   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      /Users/jpadams/Documents/proj/pds/pdsen/workspace/validate/validate-2.2.0-SNAPSHOT/resources/registered_context_products.json

Product Level Validation Results

  FAIL: file:/Users/jpadams/test/validate%20189/validate189.xml
      ERROR  [error.label.context_ref_not_found]   line 30: 'Context product not found: urn:nasa:pds:context:investigation:individual.lab_shocked_foo
      ERROR  [error.label.context_ref_not_found]   line 48: 'Context product not found: urn:nasa:pds:context:instrument:sbu_cpex.foo
      ERROR  [error.validation.internal_error]   Error executing validationTask: java.lang.NullPointerException: Cannot invoke "java.io.BufferedReader.readLine()" because "reader" is null
        1 product validation(s) completed

Summary:

  3 error(s)
  0 warning(s)

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

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

  Message Types:
    2            error.label.context_ref_not_found
    1            error.validation.internal_error

End of Report
Completed execution in 5534 ms

java.io.FileNotFoundException: /Users/jpadams/test/validate%20189/validate189.xml (No such file or directory)
    at java.base/java.io.FileInputStream.open0(Native Method)
    at java.base/java.io.FileInputStream.open(FileInputStream.java:211)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:153)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:108)
    at java.base/java.io.FileReader.<init>(FileReader.java:60)
    at gov.nasa.pds.tools.util.DocumentUtil.readFile(DocumentUtil.java:97)
    at gov.nasa.pds.tools.util.DocumentUtil.getDocumentWithoutComments(DocumentUtil.java:137)
    at gov.nasa.pds.tools.util.TableUtil.countHeadersBeforeTable(TableUtil.java:52)
    at gov.nasa.pds.tools.validate.rule.pds4.TableDataContentValidationRule.validateTableDataContents(TableDataContentValidationRule.java:788)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at gov.nasa.pds.tools.validate.rule.AbstractValidationRule.execute(AbstractValidationRule.java:71)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    at gov.nasa.pds.tools.validate.task.ValidationTask.execute(ValidationTask.java:133)
    at gov.nasa.pds.tools.validate.task.BlockingTaskManager.submit(BlockingTaskManager.java:27)
    at gov.nasa.pds.tools.label.LocationValidator.validate(LocationValidator.java:275)
    at gov.nasa.pds.validate.ValidateLauncher.doValidation(ValidateLauncher.java:1333)
    at gov.nasa.pds.validate.ValidateLauncher.processMain(ValidateLauncher.java:1590)
    at gov.nasa.pds.validate.ValidateLauncher.main(ValidateLauncher.java:1636)
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at gov.nasa.pds.tools.validate.rule.AbstractValidationRule.execute(AbstractValidationRule.java:71)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    at gov.nasa.pds.tools.validate.task.ValidationTask.execute(ValidationTask.java:133)
    at gov.nasa.pds.tools.validate.task.BlockingTaskManager.submit(BlockingTaskManager.java:27)
    at gov.nasa.pds.tools.label.LocationValidator.validate(LocationValidator.java:275)
    at gov.nasa.pds.validate.ValidateLauncher.doValidation(ValidateLauncher.java:1333)
    at gov.nasa.pds.validate.ValidateLauncher.processMain(ValidateLauncher.java:1590)
    at gov.nasa.pds.validate.ValidateLauncher.main(ValidateLauncher.java:1636)
Caused by: java.lang.NullPointerException: Cannot invoke "java.io.BufferedReader.readLine()" because "reader" is null
    at gov.nasa.pds.tools.util.DocumentUtil.readFile(DocumentUtil.java:107)
    at gov.nasa.pds.tools.util.DocumentUtil.getDocumentWithoutComments(DocumentUtil.java:137)
    at gov.nasa.pds.tools.util.TableUtil.countHeadersBeforeTable(TableUtil.java:52)
    at gov.nasa.pds.tools.validate.rule.pds4.TableDataContentValidationRule.validateTableDataContents(TableDataContentValidationRule.java:788)
    ... 12 more
jordanpadams commented 2 years ago

@qchaupds if you have not gotten started on anything thus far this week, please at this to the top of the stack. if you have gotten started on something else, this is next up

qchaupds commented 2 years ago

We have good luck so far testing on the Mac. It worked OK with the spaces in the directory name:

[MT-zzzzzzzz:~/sandbox/validate] qchau%validate -R pds4.label -r report_github427_label_valid.json -s json -t src/test/resources/github427/a\ test/phe_misc_temperature_reference_20190524.xml >& t1

[MT-306609:~/sandbox/validate] qchau% cat report_github427_label_valid.json
{
  "title": "PDS Validation Tool Report",
  "configuration": {
    "version": "2.2.0-SNAPSHOT",
    "date": "2021-10-26T17:41:04Z"
  },
  "parameters": {
    "targets": "[file:/Users/qchau/sandbox/validate/src/test/resources/github427/a%20test/phe_misc_temperature_reference_20190524.xml]",
    "ruleType": "pds4.label",
    "severityLevel": "WARNING",
    "recurseDirectories": "true",
    "fileFiltersUsed": "[*.xml, *.XML]",
    "dataContentValidation": "on",
    "productLevelValidation": "on",
    "maxErrors": "100000",
    "registeredContextsFile": "src/main/resources/util/registered_context_products.json"
  },
  "productLevelValidationResults": [
    {
      "status": "PASS",
      "label": "file:/Users/qchau/sandbox/validate/src/test/resources/github427/a%20test/phe_misc_temperature_reference_20190524.xml",
      "messages": [],
      "fragments": [],
      "dataContents": []
    }
  ],
  "summary": {
    "totalErrors": 0,
    "totalWarnings": 0,
    "messageTypes": []
  }
}
jordanpadams commented 2 years ago

@qchaupds just to clarify, this is after some code updates? this failed on my mac with the current source on main

qchaupds commented 2 years ago

@jordanpadams My bad. Should of clarified that we have made some changes to get it to work. Will do more testing and check them in soon.

tloubrieu-jpl commented 2 years ago

There is a workaround for this ticket which is to use directories without space.

jordanpadams commented 2 years ago

@msbentley unfortunately this issue has taken a bit of work for us to resolve. it seems simple but directories are passed throughout the code and it is having all kinds of unexpected consequences. since we have several high priority bugs in the queue, we are planning on tabling this for the moment and will come back to it with fresh eyes once we have tackled a couple of the other bugs that do not have workarounds

jordanpadams commented 1 year ago

changing priority/severity to low. this has not been a prevalent complaint from users, so may not happen all that often

tbarnes4 commented 11 months ago

@jordanpadams I just came across this error on a linux system using validate 3.3.0. I too normally would not come across this issue, but I was validating a file in an area I do not manage.

PDS Validate Tool 

Configuration: 
   Version                       3.3.0
   Date                          2023-10-31T11:21:16Z
  Message Types:
Parameters:
   Targets                       [file:/newsbndev4/pds4_migration/newhorizons/00ForNewHorizons/Document%20Bundle/ralph/documents/mvic_inst_overview.lblx]
   Severity Level                WARNING
   Recurse Directories           true
   File Filters Used             [*.lblx, *.LBLX]
   Data Content Validation       on
   Product Level Validation      on
   Max Errors                    100000
   Registered Contexts File      [HIDDEN]/validate-3.3.0/resources/registered_context_products.json

Product Level Validation Results

  FAIL: file:/newsbndev4/pds4_migration/newhorizons/00ForNewHorizons/Document%20Bundle/ralph/documents/mvic_inst_overview.lblx
      ERROR  [error.validation.internal_error]   Error occurred while processing PDF file content for mvic_inst_overview.pdf:  Unable to read with VeraPDF standard reader. /newsbndev4/pds4_migration/newhorizons/00ForNewHorizons/Document%20Bundle/ralph/documents/mvic_inst_overview.pdf (No such file or directory)
        1 product validation(s) completed

Summary:

  1 error(s)
  0 warning(s)

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

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

  Message Types:
    1            error.validation.internal_error

End of Report
Completed execution in 4702 ms