{"record":{"id":"6ada05d2dd63ed44","repo":"Freika/dawarich","slug":"unsupported-file-format-format","errorCode":null,"errorMessage":"Unsupported file format: %{format}","messagePattern":"Unsupported file format: %(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"app/services/exports/create.rb","lineNumber":48,"sourceCode":"    safe_close.call(zipped_tempfile)\n  end\n\n  private\n\n  attr_reader :user, :export, :start_at, :end_at, :file_format\n\n  def time_framed_points\n    user\n      .points\n      .select(Point.column_names - %w[raw_data])\n      .where(timestamp: start_at.to_i..end_at.to_i)\n  end\n\n  def build_export_tempfile\n    case file_format.to_sym\n    when :json then Exports::PointGeojsonSerializer.new(time_framed_points).call\n    when :gpx  then Exports::PointGpxSerializer.new(time_framed_points, export.name).call\n    else raise ArgumentError, I18n.t('services.exports.create.unsupported_file_format', format: file_format)\n    end\n  end\n\n  def notify_export_finished\n    I18n.with_locale(user.locale) do\n      Notifications::Create.new(\n        user:,\n        kind: :info,\n        title: I18n.t('services.exports.create.export_finished'),\n        content: I18n.t('services.exports.create.export_name_successfully_finished', name: export.name)\n      ).call\n    end\n  end\n\n  def notify_export_failed(error)\n    I18n.with_locale(user.locale) do\n      Notifications::Create.new(\n        user:,","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/services/exports/create.rb#L30-L66","documentation":"Raised as ArgumentError by Exports::Create#build_export_tempfile when export.file_format is anything other than 'json' or 'gpx' (compared as symbols after to_sym). Only those two serializers exist; every other value falls to the else branch. The surrounding #call rescues it, marks the export failed with this message, and notifies the user.","triggerScenarios":"An Export record whose file_format column holds a legacy or hand-entered value ('csv', 'geojson', 'GPX ' with whitespace/case issues aside — note 'gpx'.to_sym is fine but 'GPX'.to_sym is :GPX and fails the case), or API clients creating exports with an unsupported format that DB/validation did not restrict.","commonSituations":"Old rows created before a format was removed, seeds/fixtures with arbitrary strings, direct SQL edits, enum-style validation missing on the Export model so any string reaches the service, or a new UI option shipped before its serializer.","solutions":["Check the export's file_format value (Export.find(id).file_format) and correct it to 'json' or 'gpx'.","Add an inclusion validation on Export.file_format (%w[json gpx]) so bad values are rejected at creation, not at job time.","Normalize input (strip/downcase) when creating the export so 'GPX' or ' json' cannot be stored.","If you need the format, implement an Exports::*Serializer and add a when branch."],"exampleFix":"# before\nExport.create!(file_format: 'csv') # later: ArgumentError: Unsupported file format: csv\n\n# after\n# app/models/export.rb\nclass Export < ApplicationRecord\n  validates :file_format, inclusion: { in: %w[json gpx] }\nend\nExport.create!(file_format: 'gpx')","handlingStrategy":"validation","validationCode":"EXPORT_FORMATS = %w[json gpx].freeze\nEXPORT_FORMATS.include?(export.file_format.to_s.downcase.strip) || raise(ArgumentError, 'unsupported export format')","typeGuard":"def supported_export_format?(f) = %w[json gpx].include?(f.to_s.downcase.strip)","tryCatchPattern":"begin\n  Exports::Create.new(export:).call\nrescue ArgumentError => e\n  export.update!(status: :failed, error_message: e.message) # already handled by service rescue\nend","preventionTips":["Add an inclusion validation on Export.file_format so bad values never persist.","Restrict the UI/API format dropdown to implemented serializers.","Migrate or delete legacy rows when removing a format."],"tags":["export","file-format","validation","ruby"],"backgroundTag":"unsupported-file-format","analyzedSha":"97fad417c5a11b0eb11157890635e015723a2e97","analyzedAt":"2026-08-21T17:04:17.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}