question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting PRICE, LATITUDE, LONGITUDE parameters the wrong way returns Server Code 200 w/ no data.

See original GitHub issue

Overview

  • Client ID: jyHeS_MVualewtI_Ab4wHg
  • Issue type: bug
  • Summary: Setting price parameter the wrong way returns server code 200 and no data.
  • Platform: node-fetch (via React Native)

Description

I noticed that when I set the price parameter to 1,2,3,4 instead of 1, 2, 3, 4, the API will return an error with a server code of 200.

Endpoint

GraphQL Search API

Parameters or Sample Request

https://api.yelp.com/v3/graphql

POST body:

{
	search(term: "Restaurants", latitude: 40.747479, longitude: -73.98722, open_now: true, price: "1,2,3,4", radius: 10000, limit: 35) {
		business {
			name
			is_closed
			url
			phone
			display_phone
			review_count
			rating
			price
			photos
			distance
			attributes
			categories {
				title
				alias
			}
			location {
				address1
				address2
				address3
				city
				state
				zip_code
				country
			}
			coordinates {
				latitude
				longitude
			}
			hours {
				is_open_now
				open {
					day
					start
					end
					is_overnight
				}
			}
			reviews {
				text
				rating
				user {
					image_url
					name
				}
				time_created
				url
			}
		}
	}
}

Response

screen shot 2018-06-24 at 1 27 23 pm

Extra information

  1. Setting the price parameter a different way should not throw this kind of error.
  2. Throwing this kind of error should return a server code 500, not 200.
  3. The errors are not parsable using JSON.stringify() (without replacing characters) because they’re not really JSON due to the string characters being ' instead of ".

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
dan98765commented, Jun 27, 2018

For 3:

the error message not being parseable as valid json

I can just make it valid JSON with the quotes escaped… but on further thought I’m now leaning towards just changing the outputs to be more string-like.

Instead of:

{
	"errors": [
		{
			"message": "{'error': {'code': 'LOCATION_MISSING', 'description': 'You must specify either a location or a latitude and longitude to search.'}}",
			"locations": [
				{
					"line": 2,
					"column": 3
				}
			]
		}
	],
	"data": {...data goes here...}
}

The output would be more like:

{
	"errors": [
		{
			"message": "LOCATION_MISSING: You must specify either a location or a latitude and longitude to search.",
			"locations": [
				{
					"line": 2,
					"column": 3
				}
			]
		}
	],
	"data": {...data goes here...}
}

This feels a bit more in-line with other graphql implementations out there. We’d have the error string format be “CODE: DESCRIPTION”.

2reactions
dan98765commented, Jun 26, 2018

latitude=0.0 causes server error

This fix is now live also; I checked that:

{
  search(term: "Restaurants", latitude: 0, longitude: 180, radius: 10000, limit: 35) {..OMITTED..}
}

no longer errors out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get Started | Maps Static API - Google Developers
The Maps Static API uses numbers (latitude and longitude values) or strings ... will return the same map coverage area as a request...
Read more >
Service output—ArcGIS REST APIs
Details: "Invalid reverse geocode values provided in input" This error is returned when the location parameter in a reverseGeocode request includes a value...
Read more >
Getting the location from an IP address - php - Stack Overflow
You could download a free GeoIP database and lookup the IP address locally, or you could use a third party service and perform...
Read more >
OpenCage Geocoding API Documentation
The value is a point with latitude, longitude coordinates in decimal format. Values that are not valid coordinates are ignored. roadinfo. When set...
Read more >
Bing Ads API Operation Error Codes - Microsoft Learn
The corresponding Symbolic Error Code table entries below are noted as Not applicable. Some symbolic error codes begin with the strings ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found