closeio icon indicating copy to clipboard operation
closeio copied to clipboard

list_leads email query returning 0 results

Open mgoren opened this issue 7 years ago • 11 comments

Sometime in the last few days search queries such as the following have stopped returning any results for me:

client.list_leads(email: "[email protected]") 
# RESPONSE: {"has_more"=>false, "total_results"=>0, "data"=>[]}

Other queries are still working fine. For example this works: client.list_leads(name: "Example")

I also tested the API in python with the following and it worked fine: lead_results = client.get('lead', params={'query': 'email:"[email protected]"'})

Any idea if something changed with the Close API recently that would have caused this issue?

(I'm using gem v3.1.0.)

Thanks!

mgoren avatar Jul 17 '18 00:07 mgoren

I assume that at one point, this call returned results as expected?

client.list_leads(email: "[email protected]") 

taylorbrooks avatar Jul 17 '18 15:07 taylorbrooks

I just tested against my Close.io instance and it works as expected.

If you paste the email you're searching for into the Close.io app, do you get results? Maybe the email you're searching for was removed or the contact itself was removed.

taylorbrooks avatar Jul 17 '18 15:07 taylorbrooks

Weird! Thanks so much for looking into that for me.

Yes, that call did work fine in the past, and it still works fine searching for that email within the Close.io app and using the sample python code provided by Close. Is there maybe an alternate syntax I can use with your gem to test finding a lead by email? Maybe client.get(...)?

Thanks!

mgoren avatar Jul 17 '18 17:07 mgoren

What's the result of this?

client.list_leads('[email protected]')

taylorbrooks avatar Jul 17 '18 17:07 taylorbrooks

That works. So I think I figured this out. In my testing outside of my app I was searching with code such as the following:

client.list_leads(email: "[email protected]")
# total_results == 0

But actually email: needs to be in quotes as well, as follows:

client.list_leads("email: [email protected]")
# total_results == 4 (though only one lead actually has that exact email)

This despite the fact that it seems to work either way for a name query:

client.list_leads(name: "Test")
client.list_leads("name: Test")
# These 2 queries return the same results.

An additional piece of why I had difficulty troubleshooting this is because even though my production app does the email query the way that works, all of the emails I was using for testing began returning more than one result (a recent change it seems), and my code expects total_results to equal 1 when doing an email query. For some reason Close (even in the app) often returns extraneous results even when searching for a specific email (results with similar emails for example), but I believe that in the past when querying via the API with an email query it actually did formerly return just the 1 result.

Thanks so much for your help and your work on this! If you know of a way to query Close to get it to only return the results with exact matching email, that would be great to know. I suppose I could just limit to 1 result and assume the first one is the one that matches most closely.

Thanks again for your help.

mgoren avatar Jul 17 '18 18:07 mgoren

I am tracking the same issue, it stopped working for us yesterday or so. Our code also was running fine before, and I just tested that solution @mgoren came with. Thank you. Even it is a workaround, it will help. Still looking for what changed back there.

quantummachina avatar Jul 17 '18 22:07 quantummachina

Something must've changed on the API side then.

Any changes in the service that would have an effect here?

cc @philfreo @nickpersico

taylorbrooks avatar Jul 17 '18 22:07 taylorbrooks

@taylorbrooks @quantummachina @mgoren Thanks. I've pinged the team about this and we'll chime in soon.

nickpersico avatar Jul 18 '18 02:07 nickpersico

We are in the middle of migrating to some new infrastructure and it looks like it created this change in the search behavior. I will give another update shortly once we get to the bottom of this.

jkemp101 avatar Jul 24 '18 17:07 jkemp101

Upon further experimentation, I figured out a fix.

Originally I had been searching as follows:

client.list_leads(email: "[email protected]")
# worked in the past but now returns 0 results

When that stopped working, I changed to the code I mentioned above:

client.list_leads("email: [email protected]")
# returns multiple results, including extraneous ones

This successfully returned results, but included extraneous ones. To retrieve only exact matches I included quotes around the entire query but also around the email within the query:

client.list_leads('email: "[email protected]"')
# returns just the exact match

mgoren avatar Jul 24 '18 20:07 mgoren

Following-up on this issue. We are in the middle of adding some more sophisticated email searching functionality by parsing addresses around the @ symbol. But this actually got inadvertently triggered in this particular case because the search terms are being single quoted instead of double quoted.

I believe all that needs to be done is change this line https://github.com/taylorbrooks/closeio/blob/94e52325ff2f1d8a76a0aee4586533a55efe3aab/lib/closeio/client.rb#L75 to query.map { |k,v| "#{k}:\"#{v}\"" }.join(' ') so it uses double quotes.

Should probably also check if it is already wrapped in quotes just to be safe.

jkemp101 avatar Aug 28 '18 21:08 jkemp101

I believe this issue has been fixed, but in the event that it hasn't, please open a new issue.

taylorbrooks avatar Sep 29 '22 22:09 taylorbrooks