Improve geo validation error log when polygon ring contains > 200 vertices or hit edge cross error.

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Integration
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      https://jira.mongodb.org/browse/SERVER-125656 improved the validation diagnostic output when the geo index validation failed.  

       

      We need three more improvements in logging the diagnostic detail when geo validation hit some error. 

       

      1.The diagnostic output in the log may have the exact error truncated, when the polygon ring contains large number of vertices. 

      For instance,  `underlyingReason: \"Loop is not valid:` , but the exact reason is truncated, due to the long list of vertices in the polygon ring.  ( I deleted some coordinates in the list, since the original list exceed the length limit of JIRA comment. )

      {"t":{"$date":"2026-08-05T01:26:17.278+00:00"},"s":"I",  "c":"STORAGE",  "id":12565600,"ctx":"initandlisten","msg":"Could not build index key","attr":{"indexName":"geometry_2dsphere","recordId":"461348","failingPath":"geometry","failingElement":{"type":"MultiPolygon","coordinates":[[[[148.877916,-31.440324],[148.877918,-31.440414],[148.878707,-31.440368],[148.879441,-31.440255],[148.879546,-31.440253],[148.879545,-31.440208],[148.879598,-31.440208],[148.879808,-31.440204],[148.879807,-31.440159],[148.879912,-31.440158],[148.879911,-31.440112],[148.879964,-31.440112],[148.880174,-31.440108],[148.880174,-31.440063],[148.880331,-31.440061],[148.88033,-31.440016],[148.880488,-31.440013],[148.880487,-31.439968],[148.88054,-31.439967],[148.880645,-31.439966],[148.880644,-31.439921],[148.880697,-31.43992],[148.880802,-31.439918],[148.880801,-31.439873],[148.880854,-31.439872],[148.880959,-31.439871],[148.880958,-31.439826],[148.881011,-31.439825],[148.881116,-31.439823],[148.881115,-31.439778],[148.88122,-31.439776],[148.881273,-31.439776],[148.881272,-31.43973],[148.881377,-31.439729],[148.88143,-31.439728],[148.881429,-31.439683],[148.881534,-31.439681],[148.881586,-31.43968],[148.881586,-31.439635],[148.881691,-31.439634],[148.881743,-31.439633],[148.881742,-31.439588],[148.881848,-31.439586],[148.8819,-31.439585],[148.881899,-31.43954],[148.882005,-31.439539],[148.882057,-31.439538],[148.882056,-31.439493],[148.882109,-31.439492],[148.882214,-31.43949],[148.882213,-31.439445],[148.882266,-31.439444],[148.882371,-31.439443],[148.88237,-31.439398],[148.882423,-31.439397],[148.882528,-31.439395],[148.882527,-31.43935],[148.882579,-31.439349],[148.882685,-31.439348],[148.882684,-31.439303],[148.882842,-31.4393],[148.882841,-31.439255],[148.882998,-31.439253],[148.882997,-31.439207],[148.86757,-31.453696],[148.867439,-31.453879],[148.867516,-31.45393],[148.867552,-31.454046],[148.867414,-31.454067],[148.867412,-31.453977],[148.867359,-31.453978],[148.867273,-31.453871],[148.867076,-31.454009],[148.866992,-31.454028],[148.866971,-31.454001],[148.866821,-31.453922],[148.867059,-31.453847],[148.867004,-31.45369],[148.866826,-31.45367],[148.866827,-31.453715],[148.866775,-31.453716],[148.866754,-31.453832],[148.866517,-31.45399],[148.866465,-31.453991],[148.866464,-31.453946],[148.866358,-31.453948],[148.866306,-31.453949],[148.866307,-31.453994],[148.866254,-31.453995],[148.866201,-31.453995],[148.866202,-31.45404],[148.86615,-31.454041],[148.866097,-31.454042],[148.866098,-31.454087],[148.865993,-31.454089],[148.865994,-31.454134],[148.865941,-31.454135],[148.865653,-31.454295],[148.865629,-31.45432],[148.865577,-31.454321],[148.865524,-31.454322],[148.865525,-31.454367],[148.864967,-31.45463],[148.8649,-31.454692],[148.864713,-31.454669],[148.864667,-31.454721],[148.864556,-31.454762],[148.864512,-31.454859],[148.864483,-31.454879],[148.86443,-31.45488],[148.864431,-31.454925],[148.864332,-31.455089],[148.864092,-31.455138],[148.864061,-31.455128],[148.863992,-31.455551],[148.863996,-31.455566],[148.864077,-31.455607],[148.864131,-31.455758],[148.864396,-31.455783],[148.864397,-31.455828],[148.86445,-31.455827],[148.864451,-31.455872],[148.864503,-31.455871],[148.864644]]]]},"error":"GeoKeyExtractionFailed{ errInfo: { failingPath: \"geometry\", underlyingCode: 2, underlyingReason: \"Loop is not valid: [ [ 148.877057, -31.459604 ], [ 148.87711, -31.459603 ], [ 148.877109, -31.459558 ], [ 148.877214, -31.459557 ], [ 148.877348, -31....\", failingElement: { type: \"MultiPolygon\", coordinates: [ [ [ [ 148.877916, -31.440324 ], [ 148.877918, -31.440414 ], [ 148.878707, -31.440368 ], [ 148.879441, -31.440255 ], [ 148.879546, -31.440253 ], [ 148.879545, -31.440208 ], [ 148.879598, -31.440208 ], [ 148.879808, -31.440204 ], [ 148.879807, -31.440159 ], [ 148.879912, -31.440158 ], [ 148.879911, -31.440112 ], [ 148.879964, -31.440112 ], [ 148.880174, -31.440108 ], [ 148.880174, -31.440063 ], [ 148.880331, -31.440061 ], [ 148.88033, -31.440016 ], [ 148.880488, -31.440013 ], [ 148.880487, -31.439968 ], [ 148.88054, -31.439967 ], [ 148.880645, -31.439966 ], [ 148.880644, -31.439921 ], [ 148.880697, -31.43992 ], [ 148.880802, -31.439918 ], [ 148.880801, -31.439873 ], [ 148.880854, -31.439872 ], [ 148.880959, -31.439871 ], [ 148.880958, -31.439826 ], [ 148.881011, -31.439825 ], [ 148.881116, -31.439823 ], [ 148.881115, -31.439778 ], [ 148.88122, -31.439776 ], [ 148.881273, -31.439776 ], [ 148.881272, -31.43973 ], [ 148.881377, -31.439729 ], [ 148.88143, -31.439728 ], [ 148.881429, -31.439683 ], [ 148.881534, -31.439681 ], [ 148.881586, -31.43968 ], [  [ 148.870303, -31.453797 ], [ 148.870265, -31.453841 ], [ 148.870168, -31.453779 ], [ 148.870076, -31.453436 ], [ 148.869867, -31.453413 ], [ 148.869734, -31.453504 ], [ 148.869624, -31.453631 ], [ 148.869454, -31.453449 ], [ 148.869394, -31.453385 ], [ 148.869188, -31.453318 ], [ 148.869102, -31.45321 ], [ 148.869025, -31.453095 ], [ 148.868971, -31.453033 ], [ 148.868898, -31.4531","record":{"_id":{"$oid":"6882380ded93341fe8b4f21a"},"objectId":465470,"__v":0,"_changeHash":"465470||||||","_deleted":true,"_lastSeen":{"$date":"2025-07-24T13:45:35.979Z"},"area":2004119784,"category":3,"createdAt":{"$date":"2025-07-24T13:41:32.365Z"},"dCategory":"Vegetation Category 3","dGuideline":"v5b","endDate":{"$date":"3000-01-01T00:00:00.000Z"},"geometry":{"type":"MultiPolygon","coordinates":[[[[148.877916,-31.440324],[148.877918,-31.440414],[148.878707,-31.440368],[148.879441,-31.440255],[148.879546,-31.440253],[148.879545,-31.440208],[148.879598,-31.440208],[148.879808,-31.440204],[148.879807,-31.440159],[148.879912,-31.440158],[148.879911,-31.440112],[148.879964,-31.440112],[148.880174,-31.440108],[148.880174,-31.440063],[148.880331,-31.440061],[148.88033,-31.440016],[148.880488,-31.440013],[148.880487,-31.439968],[148.88054,-31.439967],[148.880645,-31.439966],[148.880644,-31.439921],[148.880697,-31.43992],[148.880802,-31.439918],[148.880801,-31.439873],[148.880854,-31.439872],[148.880959,-31.439871],[148.880958,-31.439826],[148.881011,-31.439825],[148.881116,-31.439823],[148.881115,-31.439778],[148.88122,-31.439776],[148.881273,-31.439776],[148.881272,-31.43973],[148.881377,-31.439729],[148.88143,-31.439728],[148.881429,-31.439683],[148.881534,-31.439681],[148.881586,-31.43968],[148.881586,-31.439635],[148.881691,-31.439634],,[148.865524,-31.454322],[148.865525,-31.454367],[148.864967,-31.45463],[148.8649,-31.454692],[148.864713,-31.454669],[148.864667,-31.454721],[148.864556,-31.454762],[148.864512,-31.454859],[148.864483]]]]}}},"truncated":{"failingElement":{"truncated":{"coordinates":{"truncated":{"0":{"truncated":{"0":{"truncated":{"428":{"truncated":{"1":{"type":"double","size":8}},"omitted":1}},"omitted":154}}}},"omitted":2}}},"error":{"type":"string","size":19230},"record":{"truncated":{"geometry":{"truncated":{"coordinates":{"truncated":{"0":{"truncated":{"0":{"truncated":{"413":{"truncated":{"1":{"type":"double","size":8}},"omitted":1}},"omitted":169}}}},"omitted":2}}}},"omitted":7}},"size":{"failingElement":21007,"record":21370}} 

       

      This is because the error message is constructed by putting the coordinates, followed by the cause of error here.

                  return BAD_VALUE("Loop is not valid: " << boundedSnippet(coordinateElt) << " " << err); 

      We should further improve the validation diagnostic output, by put the `err` before the list of `coordinates`.  That will ensure we have the exact cause of failure, even if the polygon ring contains large number of vertices. 

       

      2.  The vertices coordinates are truncated to 6 digits after `.`, while the exact digits in customer's input have more digits.

       

      See the error msg `Edges 2 and 4 cross. Edge locations in degrees: [46.1888319, 4.8115883][46.1887980, 4.8115625] and [46.1888092, 4.8115710][46.1887983, 4.8115629]` .    The customer's input is like [ 4.81142252693433, 46.18876154820097 ]. 

       

      "error": "GeoKeyExtractionFailed\{ errInfo: { failingPath: \"geometry\", underlyingCode: 2, underlyingReason: \"Loop is not valid: [ [ 4.81142252693433, 46.18876154820097 ], [ 4.811501068171559, 46.18886207809451 ], [ 4.811588259061592, 46.18883186550936 ], [ 4....\", failingElement: { type: \"MultiPolygon\", coordinates: [ [ [ [ 4.811226217866466, 46.18898265079749 ], [ 4.811317238275853, 46.18895057596577 ], [ 4.811283226940453, 46.18890247896521 ], [ 4.811208908735448, 46.18892978404372 ], [ 4.811226217866466, 46.18898265079749 ] ] ], [ [ [ 4.811197722265344, 46.18866965386717 ], [ 4.811251979494753, 46.18874174776973 ], [ 4.811322527742207, 46.18871810561532 ], [ 4.811284972493401, 46.18864124200888 ], [ 4.811197722265344, 46.18866965386717 ] ] ], [ [ [ 4.81142252693433, 46.18876154820097 ], [ 4.811501068171559, 46.18886207809451 ], [ 4.811588259061592, 46.18883186550936 ], [ 4.811562500735455, 46.18879804860283 ], [ 4.811570979909139, 46.18880918052022 ], [ 4.811562899999999, 46.18879829999997 ], [ 4.811549000000002, 46.188777 ], [ 4.8114849, 46.18869609999993 ], [ 4.81148472883446, 46.18869587596835 ], [ 4.811453177540669, 46.18870791721749 ], [ 4.811478906015401, 46.18874083390175 ], [ 4.81142252693433, 46.18876154820097 ] ] ] ] } } }: Could not extract geo keys at path 'geometry' for document with _id ObjectId('67ec0e1a0ce91765b656f192'): Loop is not valid: [ [ 4.81142252693433, 46.18876154820097 ], [ 4.811501068171559, 46.18886207809451 ], [ 4.811588259061592, 46.18883186550936 ], [ 4.811562500735455, 46.18879804860283 ], [ 4.811570979909139, 46.18880918052022 ], [ 4.811562899999999, 46.18879829999997 ], [ 4... Edges 2 and 4 cross. Edge locations in degrees: [46.1888319, 4.8115883]-[46.1887980, 4.8115625] and [46.1888092, 4.8115710]-[46.1887983, 4.8115629]",
      

      3. The longitude and latitude is switched in the above "Edge locations in degrees" message.

            Assignee:
            Unassigned
            Reporter:
            Jinfeng Ni
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: