{"record":{"id":"fdbd172f6fd8858a","repo":"Freika/dawarich","slug":"name","errorCode":null,"errorMessage":"name","messagePattern":"name","errorType":"validation","errorClass":"ActionController::ParameterMissing","httpStatus":422,"severity":"warning","filePath":"app/controllers/api/v1/visits/select_place_controller.rb","lineNumber":23,"sourceCode":"    visit = current_api_user.scoped_visits.find(params[:id])\n    place = Visits::SelectPlace.new(user: current_api_user, visit: visit, photon: photon_params).call\n    render json: serialize_place(place), status: :created\n  rescue ActiveRecord::RecordNotFound\n    render json: { error: I18n.t('controllers.api.v1.visits.select_place.visit_not_found') }, status: :not_found\n  rescue ActiveRecord::RecordInvalid, ActionController::ParameterMissing => e\n    render json: { error: e.message }, status: :unprocessable_entity\n  end\n\n  private\n\n  def photon_params\n    params.require(:photon).permit(\n      :name, :latitude, :longitude,\n      :osm_id, :osm_type, :osm_key, :osm_value,\n      :city, :country, :street, :housenumber, :postcode,\n      geodata: {}\n    ).tap do |p|\n      raise ActionController::ParameterMissing, :name      if p[:name].blank?\n      raise ActionController::ParameterMissing, :latitude  if p[:latitude].blank?\n      raise ActionController::ParameterMissing, :longitude if p[:longitude].blank?\n\n      lat = p[:latitude].to_f\n      lon = p[:longitude].to_f\n      raise ActionController::ParameterMissing, :latitude  unless lat.between?(-90, 90)\n      raise ActionController::ParameterMissing, :longitude unless lon.between?(-180, 180)\n    end\n  end\n\n  def serialize_place(place)\n    tags = place.tags.to_a\n    first_tag = tags.first\n\n    {\n      id: place.id,\n      name: place.name,\n      latitude: place.lat,","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/controllers/api/v1/visits/select_place_controller.rb#L5-L41","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Include a non-empty photon[name] string in the request body","Align client payload keys with the permit list: name, latitude, longitude, osm_*, city, country, street, housenumber, postcode, geodata","Show a required-field validation message in the UI before submitting instead of relying on the 422","When consuming the error, map {error: 'name'} to a human 'Name is required' message"],"exampleFix":"# before\npost '/api/v1/visits/select_place', params: { photon: { latitude: 52.5, longitude: 13.4 } }\n\n# after\npost '/api/v1/visits/select_place', params: { photon: { name: 'Home', latitude: 52.5, longitude: 13.4 } }","handlingStrategy":"validation","validationCode":"function validatePhotonPayload(p) {\n  return p != null && typeof p.name === 'string' && p.name.trim() !== ''\n}\n// skip the request entirely when false","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mark name as a required field in the place-picking form and block submit when empty","Reuse the exact permit-list keys (name, latitude, longitude, ...) in client payloads","When handling the 422, map {error: 'name'} to a human-readable 'Name is required' message"],"tags":["rails","api","strong-parameters","validation","visits"],"backgroundTag":"missing-required-parameter","analyzedSha":"97fad417c5a11b0eb11157890635e015723a2e97","analyzedAt":"2026-08-21T17:04:17.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}