we-promise/sure · error · Thor::Error

#{reserved.join(', ')} #{reserved.one? ? 'is' : 'are'} alrea

Error message

#{reserved.join(', ')} #{reserved.one? ? 'is' : 'are'} already provided by the items table. Remove #{reserved.one? ? 'it' : 'them'} from the command: the standard column serves the same purpose, and redeclaring would abort db:migrate with "you can't define an already defined column".

What it means

Raised as Thor::Error by the provider family generator (lib/generators/provider/family/family_generator.rb:75) when any --fields entry names a column already provided by the generated items table (RESERVED_ITEM_COLUMNS, which includes family_id, institution_id, etc.). Declaring such a column would make the generated migration abort db:migrate with Rails' "you can't define an already defined column", so the generator refuses up front.

Source

Thrown at lib/generators/provider/family/family_generator.rb:75

  argument :fields, type: :array, default: [], banner: "field:type[:secret] field:type[:secret]"

  class_option :skip_migration, type: :boolean, default: false, desc: "Skip generating migration"
  class_option :skip_routes, type: :boolean, default: false, desc: "Skip adding routes"
  class_option :skip_view, type: :boolean, default: false, desc: "Skip generating view"
  class_option :skip_controller, type: :boolean, default: false, desc: "Skip generating controller"
  class_option :skip_adapter, type: :boolean, default: false, desc: "Skip generating adapter"
  class_option :type, type: :string, default: "investment",
               enum: %w[banking investment],
               desc: "Provider type: banking (transactions only) or investment (holdings + activities)"

  def validate_fields
    if parsed_fields.empty?
      say "Warning: No fields specified. You'll need to add them manually later.", :yellow
    end

    reserved = parsed_fields.map { |f| f[:name] } & RESERVED_ITEM_COLUMNS
    if reserved.any?
      raise Thor::Error,
            "#{reserved.join(', ')} #{reserved.one? ? 'is' : 'are'} already provided by the " \
            "items table. Remove #{reserved.one? ? 'it' : 'them'} from the command: the " \
            "standard column serves the same purpose, and redeclaring would abort db:migrate " \
            "with \"you can't define an already defined column\"."
    end

    # Validate field types
    parsed_fields.each do |field|
      unless %w[text string integer boolean].include?(field[:type])
        raise Thor::Error, "Invalid field type '#{field[:type]}' for #{field[:name]}. Must be one of: text, string, integer, boolean"
      end
    end
  end

  def generate_migration
    return if options[:skip_migration]

    migration_template "migration.rb.tt",

View on GitHub (pinned to e69894adb9)

Solutions

  1. Remove the listed reserved name(s) from the fields argument — the generator adds them automatically.
  2. If you need a DIFFERENT concept, rename your field (e.g. external_family_ref:string) instead of reusing the reserved name.
  3. Run rails g provider:family --help to see the field syntax and the provider template's standard columns.

Example fix

// before
rails g provider:family acme family_id:string api_key:text

// after
rails g provider:family acme api_key:text
Defensive patterns

Strategy: validation

Validate before calling

reserved = %w[family_id institution_id] # mirror RESERVED_ITEM_COLUMNS
fields = requested_fields.reject { |f| reserved.include?(f.split(':').first) }

Type guard

field_name = arg.split(':').first
!Provider::FamilyGenerator::RESERVED_ITEM_COLUMNS.include?(field_name)

Try / catch

begin
  Rails::Generators.invoke 'provider:family', args
rescue Thor::Error => e
  abort e.message # message already tells you which column(s) to drop
end

Prevention

When it happens

Trigger: Running rails g provider:family MyProvider fields like family_id:string or institution_id:uuid — names the generator itself emits into the item migration template.

Common situations: Copy-pasting an existing provider's column list into the generator command without stripping the standard columns; assuming you must declare the family foreign key yourself.

Related errors


AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21). Data as JSON: /api/errors/4119de36092ab764. Report an issue: GitHub.