{"record":{"id":"eed529dde8284999","repo":"carrierwaveuploader/carrierwave","slug":"version-version-doesn-t-exist","errorCode":null,"errorMessage":"Version #{version} doesn't exist!","messagePattern":"Version #(.+?) doesn't exist!","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/carrierwave/uploader/versions.rb","lineNumber":265,"sourceCode":"      #     my_uploader.url                 # => /path/to/my/uploader.gif\n      #     my_uploader.url(:thumb)         # => /path/to/my/thumb_uploader.gif\n      #     my_uploader.url(:thumb, :small) # => /path/to/my/thumb_small_uploader.gif\n      #     my_uploader.url(:query => {\"response-content-disposition\" => \"attachment\"})\n      #     my_uploader.url(:version, :sub_version, :query => {\"response-content-disposition\" => \"attachment\"})\n      #\n      # === Parameters\n      #\n      # [*args (Symbol)] any number of versions\n      # OR/AND\n      # [Hash] query params\n      #\n      # === Returns\n      #\n      # [String] the location where this file is accessible via a url\n      #\n      def url(*args)\n        if (version = args.first) && version.respond_to?(:to_sym)\n          raise ArgumentError, \"Version #{version} doesn't exist!\" if versions[version.to_sym].nil?\n          # recursively proxy to version\n          versions[version.to_sym].url(*args[1..-1])\n        elsif args.first\n          super(args.first)\n        else\n          super\n        end\n      end\n\n      ##\n      # Recreate versions and reprocess them. This can be used to recreate\n      # versions if their parameters somehow have changed.\n      #\n      def recreate_versions!(*names)\n        # As well as specified versions, we need to reprocess versions\n        # that are the source of another version.\n\n        self.cache_id = CarrierWave.generate_cache_id","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/carrierwaveuploader/carrierwave/blob/b5f0abe10ecf6500309fc83e0e8969cf57ba690e/lib/carrierwave/uploader/versions.rb#L247-L283","documentation":"`uploader.url(:version_name)` proxies to the named version: the first argument is treated as a version name whenever it responds to `to_sym` (Symbols and Strings both do). If `versions[version.to_sym]` is nil — i.e. that version was never declared with a `version :name do ... end` block in the uploader — an ArgumentError \"Version X doesn't exist!\" is raised before any URL is built. Versions disabled at runtime by `:if`/`:unless` conditions are still present in the `versions` hash, so this error specifically means the version is not defined on the class, not merely inactive.","triggerScenarios":"Calling `user.avatar.url(:thumb)` when AvatarUploader declares no `version :thumb`; a typo or wrong name (`:thumbnail` vs `:thumb`); passing a String first argument (`url('thumb')`) — it responds to `to_sym` so it is looked up as a version, not a query; passing nested version names in the wrong order (`url(:small, :thumb)` when the uploader nests `:small` inside `:thumb`); view code shared across uploaders where only some define the version.","commonSituations":"Copy-pasted views referencing a version that a particular uploader doesn't define; renaming or removing a version without sweeping views/helpers; consuming `url(params[:style])` with user-supplied style names; code assuming a version exists on the base class when it is defined only in a subclass or conditionally via `version :x, if: ...` (those are fine here — the hash still contains them).","solutions":["Declare the missing version in the uploader: `version :thumb do process resize_to_limit: [200, 200] end`.","Fix the name at the call site to match the declared symbol exactly (check with `uploader.versions.keys.inspect`).","Guard the call: `user.avatar.url(:thumb) if user.avatar.versions.key?(:thumb)`.","Never pass user input straight into `url`; map permitted style names through an allowlist hash first."],"exampleFix":"# before\n# view: <%= image_tag user.avatar.url(:thumb) %>\nclass AvatarUploader < CarrierWave::Uploader::Base\n  # no version :thumb declared\nend\n# => ArgumentError: Version thumb doesn't exist!\n\n# after\nclass AvatarUploader < CarrierWave::Uploader::Base\n  include CarrierWave::MiniMagick\n  version :thumb do\n    process resize_to_limit: [200, 200]\n  end\nend","handlingStrategy":"validation","validationCode":"def version_url(uploader, name)\n  name = name.to_sym\n  return nil unless uploader.versions.key?(name)  # same lookup url() performs\n  uploader.url(name)\nend","typeGuard":"def version_defined?(uploader, name)\n  name.respond_to?(:to_sym) && uploader.versions.key?(name.to_sym)\nend","tryCatchPattern":"begin\n  url = user.avatar.url(:thumb)\nrescue ArgumentError => e\n  raise unless e.message =~ /Version .+ doesn't exist!/\n  url = user.avatar.url  # fall back to the original file\nend","preventionTips":["Define versions in a shared base uploader or concern when many uploaders must expose the same names.","Never feed params straight into url(); map user input through an allowlist of style names first.","Assert version names in a view spec/helper test (assert image_tag renders) so renames break CI, not production.","Remember a String first argument is also treated as a version name — pass query params as a Hash (e.g. url(query: {...}))."],"tags":["carrierwave","ruby","versions","url","argumenterror","file-upload"],"backgroundTag":"invalid-argument-value","analyzedSha":"b5f0abe10ecf6500309fc83e0e8969cf57ba690e","analyzedAt":"2026-08-21T18:07:27.715Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}