{"record":{"id":"c2d87f4f45b7cc0e","repo":"we-promise/sure","slug":"invalid-field-type-field-type-for-field","errorCode":null,"errorMessage":"Invalid field type '#{field[:type]}' for #{field[:name]}. Must be one of: text, string, integer, boolean","messagePattern":"Invalid field type '#(.+?)' for #(.+?)\\. Must be one of: text, string, integer, boolean","errorType":"exception","errorClass":"Thor::Error","httpStatus":null,"severity":"error","filePath":"lib/generators/provider/family/family_generator.rb","lineNumber":85,"sourceCode":"\n  def validate_fields\n    if parsed_fields.empty?\n      say \"Warning: No fields specified. You'll need to add them manually later.\", :yellow\n    end\n\n    reserved = parsed_fields.map { |f| f[:name] } & RESERVED_ITEM_COLUMNS\n    if reserved.any?\n      raise Thor::Error,\n            \"#{reserved.join(', ')} #{reserved.one? ? 'is' : 'are'} already provided by the \" \\\n            \"items table. Remove #{reserved.one? ? 'it' : 'them'} from the command: the \" \\\n            \"standard column serves the same purpose, and redeclaring would abort db:migrate \" \\\n            \"with \\\"you can't define an already defined column\\\".\"\n    end\n\n    # Validate field types\n    parsed_fields.each do |field|\n      unless %w[text string integer boolean].include?(field[:type])\n        raise Thor::Error, \"Invalid field type '#{field[:type]}' for #{field[:name]}. Must be one of: text, string, integer, boolean\"\n      end\n    end\n  end\n\n  def generate_migration\n    return if options[:skip_migration]\n\n    migration_template \"migration.rb.tt\",\n                       \"db/migrate/create_#{table_name}_and_accounts.rb\",\n                       migration_version: migration_version\n  end\n\n  def create_adapter\n    return if options[:skip_adapter]\n\n    adapter_path = \"app/models/provider/#{file_name}_adapter.rb\"\n\n    if File.exist?(adapter_path)","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/lib/generators/provider/family/family_generator.rb#L67-L103","documentation":"Raised as Thor::Error by the provider family generator (lib/generators/provider/family/family_generator.rb:85) during validate_fields when a field declared in the fields argument has a type outside the allowed set: text, string, integer, boolean. The generator's migration template only knows how to emit those four column types, so anything else (datetime, json, decimal, uuid...) is rejected before any file is written.","triggerScenarios":"Running rails g provider:family acme issued_at:datetime token:decimal flags:json — any field:type token whose type is not exactly one of text/string/integer/boolean.","commonSituations":"Porting a provider integration whose API uses timestamps or JSON blobs; muscle memory from rails g model which accepts arbitrary types.","solutions":["Change the type to one of text, string, integer, boolean — store datetimes as string (ISO8601) and JSON as text, then parse in the model.","Generate with valid fields and hand-edit the resulting migration to add the exotic column afterwards.","Re-run the generator; validation happens before templates, so nothing partial was created."],"exampleFix":"// before\nrails g provider:family acme issued_at:datetime\n\n// after\nrails g provider:family acme issued_at:string\n# then edit the generated model to parse it:\n# def issued_at = Time.zone.parse(super) if super","handlingStrategy":"validation","validationCode":"ALLOWED = %w[text string integer boolean]\nfields = fields.each_with_object({}) { |(n, t), h| raise ArgumentError, \"#{n}: bad type\" unless ALLOWED.include?(t) }","typeGuard":"type = arg.split(':')[1]\n%w[text string integer boolean].include?(type)","tryCatchPattern":"begin\n  Rails::Generators.invoke 'provider:family', args\nrescue Thor::Error => e\n  # message names the field and the allowed set; correct and re-run\nend","preventionTips":["Stick to text/string/integer/boolean in generator field args; add exotic columns by editing the generated migration.","Store ISO8601 timestamps as string and JSON as text; parse in the model.","Script generator invocations in a Rake task that validates field types first."],"tags":["rails","generator","thor","field-types","cli"],"backgroundTag":"generator-invalid-argument","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}