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

Badly specified dates should produce an error rather than a warning #375

Closed
adrianffletcher opened this issue Jun 25, 2019 · 4 comments
Closed

Comments

@adrianffletcher
Copy link

Describe the bug
If a date is specified in the sample.txt file in European format (DD/MM/YYYY) then a warning is produced.

To Reproduce
Run 'cicero execute' on the attached cta file.

Expected behavior
An error should be produced.

Screenshots
This is the warning produced:
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: Invalid date, _f: undefined, _strict: undefined, _locale: [object Object]
Error
at Function.createFromInputFallback (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/moment-mini/moment.min.js:1:3430)
at Yt (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/moment-mini/moment.min.js:1:21380)
at Ot (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/moment-mini/moment.min.js:1:22091)
at Tt (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/moment-mini/moment.min.js:1:22173)
at new c.parseZone (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/moment-mini/moment.min.js:1:50491)
at JSONPopulator.convertToObject (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/composer-concerto/lib/serializer/jsonpopulator.js:219:26)
at JSONPopulator.convertItem (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/composer-concerto/lib/serializer/jsonpopulator.js:198:27)
at JSONPopulator.visitField (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/composer-concerto/lib/serializer/jsonpopulator.js:150:27)
at JSONPopulator.visit (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/composer-concerto/lib/serializer/jsonpopulator.js:101:25)
at Field.accept (/Users/adrianfletcher/.nvm/versions/node/v11.10.0/lib/node_modules/@accordproject/cicero-cli/node_modules/composer-concerto/lib/introspect/decorated.js:65:24)

Additional context
If this warning is ignored then confusing errors occur when the template is uploaded to Clause.
credit-insurance@0.1.3.cta.zip
Screen Shot 2019-06-25 at 18 35 03

@jeromesimeon
Copy link
Member

Some investigation on this issue: DateTime variables without a format do not go through the same format parser which checks for bounds on days and months to ensure they are proper dates. This means in those cases, the parser's behaviour falls back to whatever moment does. In this case, it creates a moment object marked as Invalid date.

The proposed resolution would be to treat DateTime variable without format as DateTime variables using the default MM/DD/YYYY format.

@jeromesimeon
Copy link
Member

With a fix to make sure non-formatted date behave as formatted dates with MM/DD/YYYY:

Screenshot 2019-07-01 at 3 40 42 PM

@jeromesimeon
Copy link
Member

Tried on the provided sample:

bash-3.2$ ~/git/cicero/packages/cicero-cli/index.js parse 
~/git/cicero/packages/cicero-cli/index.js parse 
15:41:56 - info: Using current directory as template folder
15:41:56 - info: Loading a default sample.txt file.
15:41:59 - error: invalid syntax at line 4 col 29:

  Policy period 01/01/2019 to 31/12/2019
                              ^
Unexpected "3"

@jeromesimeon
Copy link
Member

Cicero part of this fixed in PR #379

I can't speak to the Clause issues that may or may not need additional fixes.

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

No branches or pull requests

2 participants