Freika/dawarich · warning · ActionController::ParameterMissing

name

Error message

name

What it means

The select_place endpoint (POST /api/v1/visits/select_place) requires a photon[name] parameter; ActionController::ParameterMissing with message 'name' is raised when params[:photon][:name] is blank (missing, nil, or empty string). The controller's rescue renders json {error: 'name'} with 422 Unprocessable Entity, so the client sees the bare word 'name' as the error body.

Source

Thrown at app/controllers/api/v1/visits/select_place_controller.rb:23

    visit = current_api_user.scoped_visits.find(params[:id])
    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,

View on GitHub (pinned to 97fad417c5)

Solutions

  1. Include a non-empty photon[name] string in the request body
  2. Align client payload keys with the permit list: name, latitude, longitude, osm_*, city, country, street, housenumber, postcode, geodata
  3. Show a required-field validation message in the UI before submitting instead of relying on the 422
  4. When consuming the error, map {error: 'name'} to a human 'Name is required' message

Example fix

# before
post '/api/v1/visits/select_place', params: { photon: { latitude: 52.5, longitude: 13.4 } }

# after
post '/api/v1/visits/select_place', params: { photon: { name: 'Home', latitude: 52.5, longitude: 13.4 } }
Defensive patterns

Strategy: validation

Validate before calling

function validatePhotonPayload(p) {
  return p != null && typeof p.name === 'string' && p.name.trim() !== ''
}
// skip the request entirely when false

Prevention

When it happens

Trigger: Calling select_place with a photon object that omits name, sends name as '' or null, or sends the name under a different key (e.g. title) so the permit list drops it. Any non-string falsy value also trips the blank? check.

Common situations: Frontend form sending an unnamed place (user cleared the name field), key mismatch between the client payload and the permitted attributes, testing the endpoint with a partially-built payload, a reverse place (from OSM) whose name tag was stripped during serialization.

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


AI-assisted analysis of Freika/dawarich@97fad417c5 (2026-08-21). Data as JSON: /api/errors/fdbd172f6fd8858a. Report an issue: GitHub.