Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.
This repository was archived by the owner on Nov 7, 2018. It is now read-only.

negative search distance should report a well-formed json error #214

Open
@dnesting

Description

@dnesting

User input can cause an invalid geo squery to be generated:

Stretchy::Errors::ValidationError
…0/gems/stretchy-0.4.7/lib/stretchy/utils/validation.rb:  16:in `validate!'
…gems/stretchy-0.4.7/lib/stretchy/filters/geo_filter.rb:  22:in `initialize'
…stretchy-0.4.7/lib/stretchy/builders/filter_builder.rb:  33:in `new'
…stretchy-0.4.7/lib/stretchy/builders/filter_builder.rb:  33:in `add_geo'
…/stretchy-0.4.7/lib/stretchy/builders/where_builder.rb:  45:in `add_geo'
…ms/stretchy-0.4.7/lib/stretchy/clauses/where_clause.rb: 135:in `geo'
/home/vcap/app/lib/data_magic/query_builder.rb: 132:in `search_location'
/home/vcap/app/lib/data_magic/query_builder.rb:  30:in `generate_squery'
/home/vcap/app/lib/data_magic/query_builder.rb:  13:in `from_params'
/home/vcap/app/lib/data_magic.rb:  69:in `search'

You can cause this to happen with a negative distance (though I don't know if this is the cause of all of the errors), e.g.:

https://collegescorecard.ed.gov/search/?zip=95054&distance=-5&sort=advantage:desc

Error
<h1>Internal Server Error</h1>

There have only been a handful of these errors today (e.g. https://rpm.newrelic.com/accounts/1065766/applications/8349766/traced_errors/819047-8afa292d-5a19-11e5-8d1d-b82a72d2466d). We should give the user an error message, or disregard the distance if it's negative.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions