-
-
Notifications
You must be signed in to change notification settings - Fork 157
Fix #1390: Suppress stack traces for incomplete OSM relations #1431
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
base: main
Are you sure you want to change the base?
Fix #1390: Suppress stack traces for incomplete OSM relations #1431
Conversation
When processing regional extracts, incomplete OSM relations (missing
ways or nodes) are expected and common. Previously, these exceptions
were logged with full stack traces, cluttering logs and obscuring
more critical issues.
This change:
- Adds a helper method to detect incomplete relation exceptions
- Logs incomplete relation exceptions as warnings without stack traces
- Keeps full error logging with stack traces for unexpected errors
The fix handles exceptions related to:
- Missing nodes ("Missing location for node")
- Incomplete multipolygons (empty rings, not closed, missing ways)
- GeometryException with stats indicating incomplete relations
Includes a test that verifies incomplete relations are logged as
warnings without stack traces, and fails if the fix is reverted.
Fixes onthegomap#1390
Full logs: https://github.com/onthegomap/planetiler/actions/runs/20720775627 |
- Use pattern matching for instanceof (java:S6201) - Use try-with-resources for TestAppender (java:S2093) - Add comprehensive tests for isIncompleteRelationException method: - Test all message patterns (missing node, multipolygon errors, etc.) - Test GeometryException stat matching - Test exception cause chain recursion - Test edge cases (null, empty message) - Add test for non-incomplete exceptions logged as ERROR This should improve code coverage above the 50% threshold required by SonarCloud.
|
| if (isIncompleteRelationException(e)) { | ||
| LOGGER.warn("Incomplete OSM relation {}: {}", relation.id(), e.getMessage()); | ||
| } else { | ||
| LOGGER.error("Error preprocessing OSM relation " + relation.id(), e); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this! I already have some similar handling along these lines where these "verbose" exceptions are instances of "GeometryException.Verbose", and GeometryException has a built in geometryException.log("Error processing relation") or geometryException.log("Error processing relation", stats, "osm_relation_error") if we want to include these in the summary of geometry errors that gets printed at the end.
It seems like we might be able to replace this whole PR with just changing these 2 "catch (Exception e)" blocks to something like:
} catch (GeometryException e) {
e.log("Error processing relation " + relation.id());
} catch (Exception e) {
LOGGER.error("Error preprocessing OSM relation {}", relation.id(), e);
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frankly, I don't have a strong opinion about the appearance in the log, other than avoiding a scary ERROR and a useless stack trace.
Please feel free to change the PR code in any way you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually could you share one or a few full stack traces that you're seeing? I tried adding that line but found that GeometryException is actually caught before that point and logged using that method that suppresses verbose logs already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a stack trace in #1390 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see, these geometry exceptions are normally caught and logged quietly (or not logged at all) but your profile asks for the area of a feature, and Unit.java calls applyAndWrapException which propagates any geometry exception that would have been suppressed very loudly.
What do you think the fallback should be when area/length fail to compute? Should it return 0? null? or omit the entire feature
Or more broadly, if any of the properties in a yaml file fail with an exception do you think we should just omit that property? or the entire feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are actually two questions here:
-
Should an incomplete polygon be processed at all? For example, should its attributes be computed?
IMO, if a potential feature does not have a valid geometry it should be dropped as soon as can be. -
How to handle (other) exceptions while computing attribute values?
IMO, it would be best if there is a clear error message with the OSM feature id and type, the layer.feature.name and the attribute name.
That should allow users to fix their definition/code.
Silent drop is generally not a good option. On the other hand, keeping the current stack trace is not very helpful for the user, and an unnecessary support burden for you.



When processing regional extracts, incomplete OSM relations (missing ways or nodes) are expected and common. Previously, these exceptions were logged with full stack traces, cluttering logs and obscuring more critical issues.
This change:
The fix handles exceptions related to:
Includes a test that verifies incomplete relations are logged as warnings without stack traces, and fails if the fix is reverted.
Fixes #1390