we-promise/sure · warning · Property::AvmImport::Error

{result.error}

Error message

{result.error}

What it means

Setting::ValidationError raised by Setting.validate_onboarding_state! when the proposed state is not in ONBOARDING_STATES = %w[open closed invite_only] (app/models/setting.rb:176). The message is I18n-driven (settings.hostings.update.invalid_onboarding_state). This guards self-hosted instance onboarding mode: only those three exact strings are accepted, and unlike the ENV-based default (which silently falls back to 'open' for bad values), the bang validator fails loudly.

Source

Thrown at app/models/property/avm_import.rb:63

        balance: 0,
        currency: data.currency,
        status: "draft",
        owner: owner,
        accountable: Property.new(
          subtype: data.property_type,
          year_built: data.year_built,
          area_value: data.area_value,
          area_unit: data.area_unit,
          avm_provider: provider_key,
          avm_last_synced_on: Date.current,
          # Providers only cover US addresses, so the country isn't collected
          # in the lookup form. "US" matches the manual form's placeholder.
          address_attributes: address_attributes.merge(country: "US")
        )
      )

      result = account.set_current_balance(data.valuation)
      raise Error.new(result.error) unless result.success?

      account.activate!
    end

    account.auto_share_with_family! if family.share_all_by_default?
    account
  rescue ActiveRecord::RecordInvalid => e
    raise Error.new(e.record.errors.full_messages.to_sentence.presence || e.message)
  end

  private
    attr_reader :family, :owner, :provider_key, :name, :address_attributes

    # The form marks these required, but a forged or JS-less submission can
    # bypass that — validate locally before spending a monthly-budget request
    # on a lookup that can't produce a property.
    def validate_inputs!
      missing = name.blank? ||

View on GitHub (pinned to e69894adb9)

Solutions

  1. Use one of the exact values: open, closed, invite_only
  2. Normalize/whitelist input at the controller boundary against Setting::ONBOARDING_STATES
  3. Check the I18n key settings.hostings.update.invalid_onboarding_state exists in your locale files if the message looks wrong
  4. For ENV config (ONBOARDING_STATE), remember invalid values silently coerce to 'open', not this error — this validator only runs on explicit updates

Example fix

# before
Setting.validate_onboarding_state!(params[:state]) # "invite-only" -> raises

# after
state = params[:state].to_s.underscore.tr("-", "_") unless Setting::ONBOARDING_STATES.include?(params[:state])
Setting.validate_onboarding_state!(state) # "invite_only" -> passes
Defensive patterns

Strategy: validation

Validate before calling

state = params[:state].to_s
unless Setting::ONBOARDING_STATES.include?(state)
  return render_error "state must be one of #{Setting::ONBOARDING_STATES.join(', ')}"
end

Prevention

When it happens

Trigger: Host settings update endpoint receiving a state like 'invite-only' (hyphen), 'Invites', 'public', or 'inviteOnly' — any deviation from the exact snake_case values; passing nil or an empty string; API client sending enum names from a different version.

Common situations: Frontend dropdown values drifting from backend enums; API consumers guessing state names; copy-pasting 'invite-only' from docs written with hyphens; upgrading instances where old client code sends legacy state names.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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