You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[N6] Wrong value in AddressSearch after refresh #5840
Feel free to bring this to a thread in the Slack room if you need people to help out reproducing / to talk the investigation through there - Usually gets more eyes than GH if needed, up to you!
One thing I noticed is that when we pass from the "Add Bank account" step to the "Company information" step, the url changes to /bank-account/company for a brief moment and then it goes back to /bank-account/
I would have expected it to be /bank-account/company during the 'Company information' step
So.. this makes it take you back to the first step when you reload, but the bug still happens once you add the bank account again
Since we are doing a proxy in Web-Expensify, we could filter the results there if they are incomplete (if we are not able to filter them in the front end).
Okay, I just found this SO which appears relevant. Basically in the case of 25220 Quail Ridge Road, Escondido, CA, 97027, Google Places is returning a best-guess partial match, and the response should include a partial_match field that we should validate is false (exact matches only).
It looks like we complete the data with a second request. The first request pulling the results list include less information in the response, which would make it a bit harder to know that some results are a problem. I guess we could still do the check if there is a number at the start to confirm that the address is complete.
Validate that one of the address_components has a types array that contains street_number
Validate that none of the address_components has a types array that contains post_box
That sounds good to me, but I would suggest doing (2) and (3) as filters in our backend so we don't show those results to the user. I think it is better experience than showing results that eventually will lead to validation errors. What do you think about that? scratch that, we can't do that there because we don't have that information at that time (autocomplete query)
That sounds good to me, but I would suggest doing (2) and (3) as filters in our backend so we don't show those results to the user. I think it is better experience than showing results that eventually will lead to validation errors. What do you think about that?
I'm not sure I understand this suggestion. I'm suggesting that if a user attempts to select an address from the GooglePlacesAutocomplete component with this properties, then we know that it's an invalid address for our purposes, and we'll display an error in the form.
I'm not sure I understand this suggestion. I'm suggesting that if a user attempts to select an address from the GooglePlacesAutocomplete component with this properties, then we know that it's an invalid address for our purposes, and we'll display an error in the form.
My suggestion was toward filtering out bad results in our backend so the user never see them, but it is not so easy as I thought.
I'll implement the validations you suggested in the front, or if you want, you can implement them, what do you prefer?
It might not be a perfect solution, but it will be an improvement from what we have currently. We can address issues with other addresses as they come up. I think we should maybe also add some unit test coverage of the saveLocationDetails function to help maintain it in the future.
Updated the PR, it is still in WIP since it is missing the suggested tests, but let me know if that implementation makes sense for you @roryabraham . Thank you!
What is the estimate on the PR being ready for review? Anything I can do to help?
Hmm, I have to update the "Steps / QA" section. I can do that now. About the tests that @roryabraham suggested, I'm having some doubts about it.
To make it easier to test, I would remove the function saveLocationDetails from AddressSearch and make it receive a callback onChangeText as a parameter. This function is very related to the AddressSearch component and probably won't be used anywhere else, so I'm a bit hesitant about moving it to a separate file just for testing purposes. Another option is to define it in the AddressSearch component file and export it from there, but I haven't seen another case where we export something else besides the component.
Activity
MelvinBot commentedon Oct 14, 2021
Triggered auto assignment to @trjExpensify (
AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.trjExpensify commentedon Oct 14, 2021
Ah yeah, I hit the
undefined,undefinedbit too. Noted that here: https://expensify.slack.com/archives/C020EPP9B9A/p1634207884072800?thread_ts=1634147967.452400&cid=C020EPP9B9AAre you taking this one on, @aldo-expensify?
roryabraham commentedon Oct 14, 2021
I'm investigating this now.
roryabraham commentedon Oct 14, 2021
I'm not able to reproduce this.
aldo-expensify commentedon Oct 14, 2021
I'll try too, maybe it has been solved 🤷
roryabraham commentedon Oct 14, 2021
jk it happens with 88 Kearney Street
MitchExpensify commentedon Oct 14, 2021
Feel free to bring this to a thread in the Slack room if you need people to help out reproducing / to talk the investigation through there - Usually gets more eyes than GH if needed, up to you!
roryabraham commentedon Oct 14, 2021
I've got a potential fix I want to try
aldo-expensify commentedon Oct 14, 2021
One thing I noticed is that when we pass from the "Add Bank account" step to the "Company information" step, the url changes to
/bank-account/companyfor a brief moment and then it goes back to/bank-account/I would have expected it to be
/bank-account/companyduring the 'Company information' stepSo.. this makes it take you back to the first step when you reload, but the bug still happens once you add the bank account again
14 remaining items
aldo-expensify commentedon Oct 14, 2021
you are right, it is missing the number :(
I guess that is an option, I'll have a look again to see if there is a way we could filter incomplete results
aldo-expensify commentedon Oct 14, 2021
I think you are probably right there
aldo-expensify commentedon Oct 14, 2021
Since we are doing a proxy in Web-Expensify, we could filter the results there if they are incomplete (if we are not able to filter them in the front end).
roryabraham commentedon Oct 14, 2021
Okay, I just found this SO which appears relevant. Basically in the case of
25220 Quail Ridge Road, Escondido, CA, 97027, Google Places is returning a best-guess partial match, and the response should include apartial_matchfield that we should validate is false (exact matches only).aldo-expensify commentedon Oct 14, 2021
It seems to be missing the
partial_matchstuff in this case.The response when we search for
25220 Quail Ridge Road, Escondido, CA, 97027:{ "predictions" : [ { "description" : "Quail Ridge Road, Escondido, CA, USA", "matched_substrings" : [ { "length" : 16, "offset" : 0 } ], "place_id" : "EiRRdWFpbCBSaWRnZSBSb2FkLCBFc2NvbmRpZG8sIENBLCBVU0EiLiosChQKEgkhAGJPs_PbgBGZpcyAIyGoBRIUChIJe0PCgV7z24AR38WWdw_I0QE", "reference" : "EiRRdWFpbCBSaWRnZSBSb2FkLCBFc2NvbmRpZG8sIENBLCBVU0EiLiosChQKEgkhAGJPs_PbgBGZpcyAIyGoBRIUChIJe0PCgV7z24AR38WWdw_I0QE", "structured_formatting" : { "main_text" : "Quail Ridge Road", "main_text_matched_substrings" : [ { "length" : 16, "offset" : 0 } ], "secondary_text" : "Escondido, CA, USA" }, "terms" : [ { "offset" : 0, "value" : "Quail Ridge Road" }, { "offset" : 18, "value" : "Escondido" }, { "offset" : 29, "value" : "CA" }, { "offset" : 33, "value" : "USA" } ], "types" : [ "route", "geocode" ] }, { "description" : "25220 Quail Ridge Road, Escondido, CA, USA", "matched_substrings" : [ { "length" : 16, "offset" : 6 }, { "length" : 9, "offset" : 24 }, { "length" : 2, "offset" : 35 } ], "place_id" : "EioyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBFc2NvbmRpZG8sIENBLCBVU0EiLiosChQKEgkhAGJPs_PbgBGZpcyAIyGoBRIUChIJe0PCgV7z24AR38WWdw_I0QE", "reference" : "EioyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBFc2NvbmRpZG8sIENBLCBVU0EiLiosChQKEgkhAGJPs_PbgBGZpcyAIyGoBRIUChIJe0PCgV7z24AR38WWdw_I0QE", "structured_formatting" : { "main_text" : "25220 Quail Ridge Road", "main_text_matched_substrings" : [ { "length" : 16, "offset" : 6 } ], "secondary_text" : "Escondido, CA, USA", "secondary_text_matched_substrings" : [ { "length" : 9, "offset" : 0 }, { "length" : 2, "offset" : 11 } ] }, "terms" : [ { "offset" : 0, "value" : "25220" }, { "offset" : 6, "value" : "Quail Ridge Road" }, { "offset" : 24, "value" : "Escondido" }, { "offset" : 35, "value" : "CA" }, { "offset" : 39, "value" : "USA" } ], "types" : [ "route", "geocode" ] }, { "description" : "25220 Quail Ridge Road, Los Gatos, CA, USA", "matched_substrings" : [ { "length" : 5, "offset" : 0 }, { "length" : 16, "offset" : 6 }, { "length" : 2, "offset" : 35 } ], "place_id" : "ChIJleyzZm05joARLy5PZi-_lQc", "reference" : "ChIJleyzZm05joARLy5PZi-_lQc", "structured_formatting" : { "main_text" : "25220 Quail Ridge Road", "main_text_matched_substrings" : [ { "length" : 5, "offset" : 0 }, { "length" : 16, "offset" : 6 } ], "secondary_text" : "Los Gatos, CA, USA", "secondary_text_matched_substrings" : [ { "length" : 2, "offset" : 11 } ] }, "terms" : [ { "offset" : 0, "value" : "25220" }, { "offset" : 6, "value" : "Quail Ridge Road" }, { "offset" : 24, "value" : "Los Gatos" }, { "offset" : 35, "value" : "CA" }, { "offset" : 39, "value" : "USA" } ], "types" : [ "premise", "geocode" ] }, { "description" : "25220 Quail Ridge Road, Lafayette, CA, USA", "matched_substrings" : [ { "length" : 16, "offset" : 6 }, { "length" : 2, "offset" : 35 } ], "place_id" : "EioyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBMYWZheWV0dGUsIENBLCBVU0EiLiosChQKEglFkwEeA2OFgBHA9dOymuW4uhIUChIJhY_6o3xghYARJ2nkA11YKPk", "reference" : "EioyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBMYWZheWV0dGUsIENBLCBVU0EiLiosChQKEglFkwEeA2OFgBHA9dOymuW4uhIUChIJhY_6o3xghYARJ2nkA11YKPk", "structured_formatting" : { "main_text" : "25220 Quail Ridge Road", "main_text_matched_substrings" : [ { "length" : 16, "offset" : 6 } ], "secondary_text" : "Lafayette, CA, USA", "secondary_text_matched_substrings" : [ { "length" : 2, "offset" : 11 } ] }, "terms" : [ { "offset" : 0, "value" : "25220" }, { "offset" : 6, "value" : "Quail Ridge Road" }, { "offset" : 24, "value" : "Lafayette" }, { "offset" : 35, "value" : "CA" }, { "offset" : 39, "value" : "USA" } ], "types" : [ "route", "geocode" ] }, { "description" : "25220 Quail Ridge Road, Cottonwood, CA, USA", "matched_substrings" : [ { "length" : 22, "offset" : 0 }, { "length" : 2, "offset" : 36 } ], "place_id" : "EisyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBDb3R0b253b29kLCBDQSwgVVNBIlISUAo0CjIJYag1F-PQ0lQRWUdj8RBzGoEaHgsQ7sHuoQEaFAoSCXsZGyUR2dJUEUcXZjSo6-y6DBCExQEqFAoSCXFam0jR1tJUEWT9gTuLBLHV", "reference" : "EisyNTIyMCBRdWFpbCBSaWRnZSBSb2FkLCBDb3R0b253b29kLCBDQSwgVVNBIlISUAo0CjIJYag1F-PQ0lQRWUdj8RBzGoEaHgsQ7sHuoQEaFAoSCXsZGyUR2dJUEUcXZjSo6-y6DBCExQEqFAoSCXFam0jR1tJUEWT9gTuLBLHV", "structured_formatting" : { "main_text" : "25220 Quail Ridge Road", "main_text_matched_substrings" : [ { "length" : 22, "offset" : 0 } ], "secondary_text" : "Cottonwood, CA, USA", "secondary_text_matched_substrings" : [ { "length" : 2, "offset" : 12 } ] }, "terms" : [ { "offset" : 0, "value" : "25220 Quail Ridge Road" }, { "offset" : 24, "value" : "Cottonwood" }, { "offset" : 36, "value" : "CA" }, { "offset" : 40, "value" : "USA" } ], "types" : [ "street_address", "geocode" ] } ], "status" : "OK" }The when we click it and it looks for details:
{ "html_attributions" : [], "result" : { "address_components" : [ { "long_name" : "Quail Ridge Road", "short_name" : "Quail Ridge Rd", "types" : [ "route" ] }, { "long_name" : "Escondido", "short_name" : "Escondido", "types" : [ "locality", "political" ] }, { "long_name" : "San Diego County", "short_name" : "San Diego County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "California", "short_name" : "CA", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] }, { "long_name" : "92027", "short_name" : "92027", "types" : [ "postal_code" ] } ], "adr_address" : "\u003cspan class=\"street-address\"\u003eQuail Ridge Rd\u003c/span\u003e, \u003cspan class=\"locality\"\u003eEscondido\u003c/span\u003e, \u003cspan class=\"region\"\u003eCA\u003c/span\u003e \u003cspan class=\"postal-code\"\u003e92027\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eUSA\u003c/span\u003e", "formatted_address" : "Quail Ridge Rd, Escondido, CA 92027, USA", "geometry" : { "location" : { "lat" : 33.1037195, "lng" : -117.0338186 }, "viewport" : { "northeast" : { "lat" : 33.10506848029149, "lng" : -117.0324696197085 }, "southwest" : { "lat" : 33.10237051970849, "lng" : -117.0351675802915 } } }, "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/geocode-71.png", "icon_background_color" : "#7B9EB0", "icon_mask_base_uri" : "https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet", "name" : "Quail Ridge Road", "place_id" : "EihRdWFpbCBSaWRnZSBSZCwgRXNjb25kaWRvLCBDQSA5MjAyNywgVVNBIi4qLAoUChIJIQBiT7Pz24ARmaXMgCMhqAUSFAoSCXtDwoFe89uAEd_FlncPyNEB", "reference" : "EihRdWFpbCBSaWRnZSBSZCwgRXNjb25kaWRvLCBDQSA5MjAyNywgVVNBIi4qLAoUChIJIQBiT7Pz24ARmaXMgCMhqAUSFAoSCXtDwoFe89uAEd_FlncPyNEB", "types" : [ "route" ], "url" : "https://maps.google.com/?q=Quail+Ridge+Rd,+Escondido,+CA+92027,+USA&ftid=0x80dbf3b34f620021:0x5a8212380cca599", "utc_offset" : -420, "vicinity" : "Escondido" }, "status" : "OK" }aldo-expensify commentedon Oct 14, 2021
It looks like we complete the data with a second request. The first request pulling the results list include less information in the response, which would make it a bit harder to know that some results are a problem. I guess we could still do the check if there is a
numberat the start to confirm that the address is complete.roryabraham commentedon Oct 14, 2021
Okay, here's what I suggest we do:
type: addressin the query.address_componentshas atypesarray that containsstreet_numberaddress_componentshas atypesarray that containspost_boxaldo-expensify commentedon Oct 14, 2021
That sounds good to me,
but I would suggest doing (2) and (3) as filters in our backend so we don't show those results to the user. I think it is better experience than showing results that eventually will lead to validation errors. What do you think about that?scratch that, we can't do that there because we don't have that information at that time (autocomplete query)roryabraham commentedon Oct 14, 2021
I'm not sure I understand this suggestion. I'm suggesting that if a user attempts to select an address from the
GooglePlacesAutocompletecomponent with this properties, then we know that it's an invalid address for our purposes, and we'll display an error in the form.aldo-expensify commentedon Oct 14, 2021
My suggestion was toward filtering out bad results in our backend so the user never see them, but it is not so easy as I thought.
I'll implement the validations you suggested in the front, or if you want, you can implement them, what do you prefer?
roryabraham commentedon Oct 14, 2021
It might not be a perfect solution, but it will be an improvement from what we have currently. We can address issues with other addresses as they come up. I think we should maybe also add some unit test coverage of the
saveLocationDetailsfunction to help maintain it in the future.aldo-expensify commentedon Oct 14, 2021
Updated the PR, it is still in WIP since it is missing the suggested tests, but let me know if that implementation makes sense for you @roryabraham . Thank you!
MitchExpensify commentedon Oct 14, 2021
What is the estimate on the PR being ready for review? Anything I can do to help?
aldo-expensify commentedon Oct 14, 2021
Hmm, I have to update the "Steps / QA" section. I can do that now. About the tests that @roryabraham suggested, I'm having some doubts about it.
To make it easier to test, I would remove the function
saveLocationDetailsfromAddressSearchand make it receive a callbackonChangeTextas a parameter. This function is very related to theAddressSearchcomponent and probably won't be used anywhere else, so I'm a bit hesitant about moving it to a separate file just for testing purposes. Another option is to define it in theAddressSearchcomponent file and export it from there, but I haven't seen another case where we export something else besides the component.