-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
[do not merge] do not throw on name/address regex matching errors #122
base: master
Are you sure you want to change the base?
Conversation
also worth adding that the existing workflow is error-prone, in the case where a record contains multiple names in multiple languages, if one of those names is a URL then an Error is thrown and the whole record is discarded. there are solutions for this which importers can elect to implement (such as the per-setter try/catch 💩 I mentioned above) although to-date none of the importers have adopted this approach and it's unlikely custom importer authors will have the insight to do so. |
Cool, it will be good to finally have this fixed. I have two suggestions: 1.) Definitely do use |
Yeah that sounds good, although there is an issue with the chain-of-command now, since the error is not being passed back to the caller we can't say things like "skipping record" as this library has no control over that behaviour |
Oh, hm. So what will the behavior be with this PR for a record that has a name that contains a URL? |
If the record has a name with a URL it will |
Got it, and with this PR, what document would end up being stored in Elasticsearch? Would it have a property containing the URL? |
Hmm yes, I just had the same thought, and the tests don't properly cover checking that. I think we need to have a rethink about how the validation works in general. It makes sense to throw on mandatory properties in the constructor but in reality there are also additional properties which are mandatory such as a One option is that we stop throwing on all setter methods (and ensure that the property is not set) along with an appropriate log message and log level. I think this would be simpler for importers to handle due to less In order to ensure that the minimum viable set of properties is set on the object we can introduce a new method called |
Closes pelias/openstreetmap#534 |
related #116 |
this is one solution to the verbose regex matching errors.
we've had a lot of users worried and confused about the verbose errors we return when the source data for a name or address erroneously contains a URL.
there are a few ways of dealing with it, I considered returning a
PeliasModelWarning
error but solutions like that require that each importer is updated and it's not nice code because throwing will terminate the current scope, necessitating that each setter is wrapped in its owncatch
block 💩this solution is fairly clean, I'm still outputting the error message via
console.warn
and considered usingpelias-logger
although I'd prefer to reduce the coupling to other modules to this one to avoid the 'bump cascades'.