Freika/dawarich · warning · ActionController::ParameterMissing
latitude
Error message
latitude
What it means
Same strong-parameters gate as the name check: photon[latitude] must be present and non-blank or ActionController::ParameterMissing with message 'latitude' is raised, rendered by the controller rescue as json {error: 'latitude'} with 422. This is the blank check only - range validation of the parsed float happens separately at line 29.
Source
Thrown at app/controllers/api/v1/visits/select_place_controller.rb:24
place = Visits::SelectPlace.new(user: current_api_user, visit: visit, photon: photon_params).call
render json: serialize_place(place), status: :created
rescue ActiveRecord::RecordNotFound
render json: { error: I18n.t('controllers.api.v1.visits.select_place.visit_not_found') }, status: :not_found
rescue ActiveRecord::RecordInvalid, ActionController::ParameterMissing => e
render json: { error: e.message }, status: :unprocessable_entity
end
private
def photon_params
params.require(:photon).permit(
:name, :latitude, :longitude,
:osm_id, :osm_type, :osm_key, :osm_value,
:city, :country, :street, :housenumber, :postcode,
geodata: {}
).tap do |p|
raise ActionController::ParameterMissing, :name if p[:name].blank?
raise ActionController::ParameterMissing, :latitude if p[:latitude].blank?
raise ActionController::ParameterMissing, :longitude if p[:longitude].blank?
lat = p[:latitude].to_f
lon = p[:longitude].to_f
raise ActionController::ParameterMissing, :latitude unless lat.between?(-90, 90)
raise ActionController::ParameterMissing, :longitude unless lon.between?(-180, 180)
end
end
def serialize_place(place)
tags = place.tags.to_a
first_tag = tags.first
{
id: place.id,
name: place.name,
latitude: place.lat,
longitude: place.lon,View on GitHub (pinned to 97fad417c5)
Solutions
- Send photon[latitude] as a non-empty numeric string or float
- Rename any lat/lon fields in the client payload to latitude/longitude before submitting
- Guard in the UI: disable the select-place button until a coordinate is picked from the map/search result
- Treat the {error: 'latitude'} 422 body as 'Latitude is required' when surfacing to users
Example fix
// before
body: JSON.stringify({ photon: { name: 'Home', longitude: 13.4 } })
// after
body: JSON.stringify({ photon: { name: 'Home', latitude: 52.5, longitude: 13.4 } }) Defensive patterns
Strategy: validation
Validate before calling
function hasLatitude(p) {
return p != null && p.latitude !== undefined && p.latitude !== null && String(p.latitude).trim() !== ''
} Prevention
- Use the server's key names (latitude, not lat) in every client payload
- Only enable the select-place action after a map pin or search result supplies coordinates
- Treat the 422 {error: 'latitude'} body as a field-level validation signal, not a server bug
When it happens
Trigger: POST /api/v1/visits/select_place where the photon payload omits latitude, sends it as '' or null, or the client sends lat/lon under different key names (e.g. lat instead of latitude) so the permit filter drops them.
Common situations: Client code migrating from a lat/lon naming convention to latitude/longitude, geolocation permission denied so the browser returns undefined coords, copy-pasting place JSON from another API that uses different field names.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- name
- longitude
- errorData.error || `Failed to ${isEdit ? "update" : "create"
- Failed to create visit
- response.error
AI-assisted analysis of Freika/dawarich@97fad417c5 (2026-08-21).
Data as JSON: /api/errors/cc342bc32a0ba9af.
Report an issue: GitHub.