{"record":{"id":"343985939a66fb74","repo":"Freika/dawarich","slug":"longitude","errorCode":null,"errorMessage":"longitude","messagePattern":"longitude","errorType":"validation","errorClass":"ActionController::ParameterMissing","httpStatus":422,"severity":"warning","filePath":"app/controllers/api/v1/visits/select_place_controller.rb","lineNumber":25,"sourceCode":"    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,\n      longitude: place.lon,\n      source: place.source,","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/controllers/api/v1/visits/select_place_controller.rb#L7-L43","documentation":"The third strong-parameters gate: photon[longitude] blank raises ActionController::ParameterMissing with message 'longitude', rendered as json {error: 'longitude'} with 422 by the controller's rescue. Blank means missing, nil, or empty string; range validation of the parsed value happens separately at line 30.","triggerScenarios":"POST /api/v1/visits/select_place with photon lacking longitude, longitude: '' or null, or longitude nested at the wrong level (outside the photon object) so params.require(:photon) never sees it.","commonSituations":"Flattened payloads sending {name, latitude, longitude} at the top level instead of nested under photon, serialization code dropping null coords, partial place objects from a search index that lack coordinates.","solutions":["Send photon[longitude] nested inside the photon object, non-empty","Verify the whole payload shape: {photon: {name:, latitude:, longitude:, ...}} - nesting errors hit longitude first if it is the last key built","Validate the place candidate has coordinates before enabling the select action in the UI","Map the {error: 'longitude'} 422 to a 'Longitude is required' message"],"exampleFix":"// before\nbody: JSON.stringify({ name: 'Home', latitude: 52.5, longitude: 13.4 })\n\n// after\nbody: JSON.stringify({ photon: { name: 'Home', latitude: 52.5, longitude: 13.4 } })","handlingStrategy":"validation","validationCode":"function hasLongitude(p) {\n  return p != null && p.longitude !== undefined && p.longitude !== null && String(p.longitude).trim() !== ''\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Nest all place fields under the photon key - top-level keys are silently dropped by params.require(:photon)","Assert payload shape in client integration tests: {photon: {name, latitude, longitude, ...}}","Block submission until both coordinates exist, since blank lat and lon produce identical-looking 422s"],"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"}