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

No format check in new syntax style templates (e.g. type date) #485

Open
bosd opened this issue Feb 28, 2023 · 0 comments
Open

No format check in new syntax style templates (e.g. type date) #485

bosd opened this issue Feb 28, 2023 · 0 comments

Comments

@bosd
Copy link
Collaborator

bosd commented Feb 28, 2023

Currently there is no type check.
I have to admit it is my own mistake. (although might be a common one).
Which lead to a crash of my upstream application.
I'm opening this ticket to open up a discussion about the prevention of these situations.

I was converting an template from the old syntax to the the new one.

(random example)

fields:
  date:
    - Rechnungsdatum\s+(\w+ \d+, \d{4})

to

fields:
  date:
    parser: regex
    regex: Rechnungsdatum\s+(\w+ \d+, \d{4})

Notice: I forgot to include the type definition. type: date

This made invoice2data sent out an string instead of a datetime object.
The upstream application did'nt like this 😠

I think this is a very common mistake to make.. Specially if your're quickly developing a template.
Currently there was no way to notice this error up until the production environment.

Proposed Solution:

  • Should we create a warning in the logger, when the type field is forgotton in the template? Should the log message be on the warning or debug level??
    That might lead to a lot of extra debug lines. (Lazy as I am, if my destination type is string, I'm not defining the type in the template.
  • Enforce the type at least for the required fields. In the same way it was with the old syntax. Writing templates is already hard enough. So every little helper to make it easier is welcoming.
@bosd bosd changed the title No type check in new syntax style templates No format check in new syntax style templates (e.g. type date) Mar 18, 2023
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

1 participant