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

Validate tool does not PASS a bundle with a single-character filename #299

Closed
c-suh opened this issue Feb 18, 2021 · 4 comments
Closed

Validate tool does not PASS a bundle with a single-character filename #299

c-suh opened this issue Feb 18, 2021 · 4 comments
Assignees
Labels
bug Something isn't working s.low

Comments

@c-suh
Copy link

c-suh commented Feb 18, 2021

Describe the bug
Validator is failing a bundle which has a file whose name is one character long. Node POC believes this is a side effect of the regular expression enforcing that the filename not begin or end with a dash, underscore, or period.

To Reproduce
Steps to reproduce the behavior:

  1. Run validate tool on files inside
    gbo_ast_fieber-beyer_spectra_v2.0_20210211.zip

Expected behavior
1 product will fail with the following:

FAIL: /gbo_ast_fieber-beyer_spectra_v2.0_20210211_aip_v1.0.xml
Begin Content Validation: /gbo_ast_fieber-beyer_spectra_v2.0_20210211_transfer_manifest_v1.0.tab
ERROR [error.table.field_value_data_type_mismatch] table 1, record 129, field 2: Value does not match its data type 'ASCII_File_Specification_Name': The filename spec '6.xml' does not match the pattern '[A-Za-z0-9][A-Za-z0-9-.][A-Za-z0-9].[A-Za-z0-9]+'
ERROR [error.table.field_value_data_type_mismatch] table 1, record 130, field 2: Value does not match its data type 'ASCII_File_Specification_Name': The filename spec '6.tab' does not match the pattern '[A-Za-z0-9][A-Za-z0-9-.]
[A-Za-z0-9].[A-Za-z0-9]+'
End Content Validation: /gbo_ast_fieber-beyer_spectra_v2.0_20210211_transfer_manifest_v1.0.tab

Version of Software Used
Version 1.23.1

Test Data / Additional context
Bug discovered while attempting to validate one of multiple bundles submitted in NASA-PDS/operations#61. List of filename rules was provided in NASA-PDS/operations#61 (comment).

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):
Not on local desktop; run on pds-gamma.

Applicable requirements
? but I like the unicorns, so I'm leaving them
: unicorn: # 1
: unicorn: # 2

@jordanpadams
Copy link
Member

@c-suh per comment above 😆

@qchaupds
Copy link
Contributor

qchaupds commented Feb 26, 2021

The pattern for filename is defined in src/main/java/gov/nasa/pds/tools/validate/content/table/FieldValueValidator.java
and it seems to required at least two characters:

private static final Pattern asciiFileNamePattern = Pattern.compile(
"[A-Za-z0-9][A-Za-z0-9-_\.]*[A-Za-z0-9]\.[A-Za-z0-9]+");

A better pattern may be:

"[A-Za-z0-9] a star should be here [A-Za-z0-9-_\.]*[A-Za-z0-9]\.[A-Za-z0-9]+")

to accept file name with just one character.

@qchaupds
Copy link
Contributor

qchaupds commented Mar 9, 2021

With the better name pattern in place, a run of valid label provided by user accepts the single-character filename:

% validate -R pds4.label -r report_github299_label_valid.json -s json -t src/test/resources/github299/valid/gbo_ast_fieber-beyer_spectra
_v2.0_20210211_aip_v1.0.xml

% egrep "status|label" report_github299_label_valid.json
"ruleType": "pds4.label",
"status": "PASS",
"label": "file:/home/qchau/sandbox/validate/src/test/resources/github299/valid/gbo_ast_fieber-beyer_spectra_v2.0_20210211_aip_v1.0.xml",

Running against a label that points to 'bad' file names, resulted in correct error messages:

% validate -R pds4.label -r report_github299_label_invalid.json -s json -t src/test/resources/github299/invalid/gbo_ast_fieber-beyer_spect
ra_v2.0_20210211_aip_v1.0.xml

File names should not end with '_' before the dot.

% grep message report_github299_label_invalid.json | grep ASCII_File_Specification_Name
"message": "Value does not match its data type 'ASCII_File_Specification_Name': The filename spec '158_.xml' does not match the pattern '[A-Za-z0-9][A-Za-z0-9-_\.][A-Za-z0-9]\.[A-Za-z0-9]+'"
"message": "Value does not match its data type 'ASCII_File_Specification_Name': The filename spec '158_.tab' does not match the pattern '[A-Za-z0-9][A-Za-z0-9-_\.][A-Za-z0-9]\.[A-Za-z0-9]+'"
"message": "Value does not match its data type 'ASCII_File_Specification_Name': The filename spec '.tab' does not match the pattern '[A-Za-z0-9]*[A-Za-z0-9-\.]*[A-Za-z0-9]\.[A-Za-z0-9]+'"

@tloubrieu-jpl tloubrieu-jpl added this to the 04.Wilma.Rudolph milestone Mar 9, 2021
qchaupds pushed a commit that referenced this issue Mar 9, 2021
…orrect file separator for non-linux machine

1. Add test resources for github297 to src/test/resources
2. Add test resources for github299 to src/test/resources
3. Modify name pattern to allow one-character file name and correct leading zero values in FieldValueValidator.java
4. Modify hard-coded file separator to be machine-dependent in ValidateLauncher.java
5. Add 2 new tests for github297 to validate.feature
6. Add 2 new tests for github299 to validate.feature

Refs #297 #297 Content validation of ASCII_Integer field does not accept value with leading zeroes
     #299 #299 Validate tool does not PASS a bundle with a single-character filename
     #300 #300 validate -u flag reports an error on Windows
qchaupds pushed a commit that referenced this issue Mar 9, 2021
…orrect file separator for non-linux machine

1. Add test resources for github297 to src/test/resources
2. Add test resources for github299 to src/test/resources
3. Modify name pattern to allow one-character file name and correct leading zero values in FieldValueValidator.java
4. Modify hard-coded file separator to be machine-dependent in ValidateLauncher.java
5. Add 2 new tests for github297 to validate.feature
6. Add 2 new tests for github299 to validate.feature

Refs #297 #297 Content validation of ASCII_Integer field does not accept value with leading zeroes
     #299 #299 Validate tool does not PASS a bundle with a single-character filename
     #300 #300 validate -u flag reports an error on Windows
@jordanpadams
Copy link
Member

closed per #306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working s.low
Projects
None yet
Development

No branches or pull requests

4 participants