Uploaded image for project: 'Red Hat 3scale API Management'
  1. Red Hat 3scale API Management
  2. THREESCALE-6541

[Preview-only] Domain invalid in validations; I can't update the tenant from the UI

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Minor Minor
    • None
    • None
    • System
    • False
    • False
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Undefined

      While testing THREESCALE-6534, I have encountered this bug in preview:

      [b319724e-b286-4ba6-9444-2855759765cb] [mnoyabon-admin.preview01.3scale.net] [2.137.11.219] Started PATCH "/finance/settings" for 2.137.11.219 at 2020-12-21 13:56:57 +0000
      [b319724e-b286-4ba6-9444-2855759765cb] [mnoyabon-admin.preview01.3scale.net] [2.137.11.219]   Account Exists (1.7ms)  SELECT  1 AS one FROM `accounts` WHERE `accounts`.`provider` = 1 AND (`accounts`.`master` = 0 OR `accounts`.`master` IS NULL) AND (`accounts`.`state` != 'scheduled_for_deletion') AND `accounts`.`self_domain` = 'mnoyabon-admin.preview01.3scale.net' LIMIT 1
      [b319724e-b286-4ba6-9444-2855759765cb] [mnoyabon-admin.preview01.3scale.net] [2.137.11.219] Processing by Finance::Provider::SettingsController#update as HTML
      [b319724e-b286-4ba6-9444-2855759765cb] [mnoyabon-admin.preview01.3scale.net] [2.137.11.219]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"dLnou511XVwnk4SiE74DKY20Y6evmGZR3jH5dK/CXvZH9oqjVcUNowJuM4V42BQ0rjJ+gxU9p0EDLPrJI7AU7Q==", "finance_billing_strategy"=>{"charging_enabled"=>"1", "currency"=>"EUR", "account_attributes"=>{"invoice_footnote"=>"", "vat_zero_text"=>"", "id"=>"2445583175001"}, "numbering_period"=>"monthly"}, "commit"=>"Save"}
      [b319724e-b286-4ba6-9444-2855759765cb] [mnoyabon-admin.preview01.3scale.net] [2.137.11.219]   Account Load (1.7ms)  SELECT  `accounts`.* FROM `accounts` WHERE `accounts`.`self_domain` = 'mnoyabon-admin.preview01.3scale.net' LIMIT 1
      ...
      [b319724e-b286-4ba6-9444-2855759765cb] [mnoyabon-admin.preview01.3scale.net] [2.137.11.219] ["Developer Portal must be a valid domain name"]
      

      With very little debugging in the Rails console, the problem is that I cannot update the billing strategy because the tenant is invalid because the domain after the obfuscator for preview is invalid according to our validations:

      irb(main):001:0> tenant = Account.tenants.find(2445583175001)
        Account Load (2.0ms)  SELECT  `accounts`.* FROM `accounts` WHERE `accounts`.`provider` = 1 AND (`accounts`.`master` = 0 OR `accounts`.`master` IS NULL) AND `accounts`.`id` = 2445583175001 LIMIT 1
      => #<Account id: 2445583175001, org_name: "Douglas-Huels", org_legaladdress: "178 Fritsch Crossroad\nEast Danielport, CT 26498-25...", created_at: "2020-06-18 08:56:51", updated_at: "2020-06-18 08:56:53", provider: true, buyer: false, country_id: nil, provider_account_id: 6, domain: "mnoyabon.preview01.3scale.net", telephone_number: nil, site_access_code: "hypnotoad", credit_card_partial_number: nil, credit_card_expires_on: nil, credit_card_auth_code: nil, master: nil, billing_address_name: "Denny Kihn", billing_address_address1: "78738 Theda Via\nKohlerberg, WA 75861", billing_address_address2: "20688 Runolfsdottir Cliff\nWisokyburgh, RI 17203-39...", billing_address_city: nil, billing_address_state: nil, billing_address_country: nil, billing_address_zip: nil, billing_address_phone: nil, org_legaladdress_cont: "", city: "", state_region: "", state: "approved", paid: false, paid_at: nil, signs_legal_terms: true, timezone: nil, delta: true, from_email: "eugenie_schroeder@friesenhuel.co.uk.e641a.example....", primary_business: nil, business_category: nil, zip: "", extra_fields: {"red_hat_account_number"=>"", "red_hat_account_verified_by"=>"", "API_Purpose_3s__c"=>"", "API_Status_3s__c"=>"", "API_Type_3s__c"=>"", "API_Onprem_3s__c"=>"", "Signup_origin"=>"", "account_type"=>"", "SFDC_Account_ID"=>"", "eval_owner"=>"", "eval_end_date"=>"", "Max-number-of-Services-Entitlement"=>"", "account-exe"=>"", "opp-number"=>""}, vat_code: nil, fiscal_code: nil, vat_rate: nil, invoice_footnote: nil, vat_zero_text: nil, default_account_plan_id: 2357356192472, default_service_id: nil, credit_card_authorize_net_payment_profile_token: nil, tenant_id: 2445583175001, self_domain: "mnoyabon-admin.preview01.3scale.net", s3_prefix: "mnoyabon", prepared_assets_version: nil, sample_data: false, proxy_configs_file_size: nil, proxy_configs_updated_at: nil, proxy_configs_content_type: nil, proxy_configs_file_name: nil, support_email: nil, finance_support_email: nil, billing_address_first_name: nil, billing_address_last_name: nil, email_all_users: true, partner_id: nil, proxy_configs_conf_file_name: nil, proxy_configs_conf_content_type: nil, proxy_configs_conf_file_size: nil, proxy_configs_conf_updated_at: nil, hosted_proxy_deployed_at: nil, po_number: "", state_changed_at: "2020-06-18 08:56:53", payment_method_id: nil>
      irb(main):002:0> tenant.billing_address
      => #<Account::BillingAddress::Address:0x0000000ef19fd8 @name="Denny Kihn", @address1="78738 Theda Via\nKohlerberg, WA 75861", @address2="20688 Runolfsdottir Cliff\nWisokyburgh, RI 17203-3994", @country=nil, @city=nil, @state=nil, @zip=nil, @phone=nil, @data={:name=>"Denny Kihn", :address1=>"78738 Theda Via\nKohlerberg, WA 75861", :address2=>"20688 Runolfsdottir Cliff\nWisokyburgh, RI 17203-3994", :country=>nil, :city=>nil, :state=>nil, :zip=>nil, :phone=>nil}, @errors=#<ActiveModel::Errors:0x0000000ef19d30 @base=#<Account::BillingAddress::Address:0x0000000ef19fd8 ...>, @messages={}, @details={}>>
      irb(main):003:0> tenant.valid?
        Account Load (1.8ms)  SELECT  `accounts`.* FROM `accounts` WHERE `accounts`.`id` = 6 LIMIT 1
        FieldsDefinition Load (1.7ms)  SELECT `fields_definitions`.* FROM `fields_definitions` WHERE `fields_definitions`.`account_id` = 6 ORDER BY `fields_definitions`.`pos` ASC
        Account Exists (1.4ms)  SELECT  1 AS one FROM `accounts` WHERE `accounts`.`self_domain` = 'mnoyabon-admin.preview01.3scale.net' AND (`accounts`.`id` != 2445583175001) LIMIT 1
        Account Exists (1.5ms)  SELECT  1 AS one FROM `accounts` WHERE (`accounts`.`id` != 2445583175001) AND ((domain = 'mnoyabon.preview01.3scale.net' OR self_domain = 'mnoyabon.preview01.3scale.net')) LIMIT 1
        Account Exists (1.4ms)  SELECT  1 AS one FROM `accounts` WHERE (`accounts`.`id` != 2445583175001) AND ((domain = 'mnoyabon-admin.preview01.3scale.net' OR self_domain = 'mnoyabon-admin.preview01.3scale.net')) LIMIT 1
        User Load (1.7ms)  SELECT  `users`.* FROM `users` WHERE `users`.`account_id` = 2445583175001 AND `users`.`role` = 'admin' AND (username <> 'saas_impersonation_admin') ORDER BY `users`.`id` ASC LIMIT 1
        User Load (1.5ms)  SELECT  `users`.* FROM `users` WHERE `users`.`account_id` = 2445583175001 AND `users`.`role` = 'admin' AND (username <> 'saas_impersonation_admin') ORDER BY `users`.`id` ASC LIMIT 1
        User Load (1.5ms)  SELECT  `users`.* FROM `users` WHERE `users`.`account_id` = 2445583175001 AND `users`.`role` = 'admin' AND (username <> 'saas_impersonation_admin') ORDER BY `users`.`id` ASC LIMIT 1
        User Load (1.6ms)  SELECT  `users`.* FROM `users` WHERE `users`.`account_id` = 2445583175001 AND `users`.`role` = 'admin' AND (username <> 'saas_impersonation_admin') ORDER BY `users`.`id` ASC LIMIT 1
      => false
      irb(main):004:0> tenant.errors.full_messages
      => ["Developer Portal must be a valid domain name"]
      irb(main):005:0> tenant.errors              
      => #<ActiveModel::Errors:0x007f627800e628 @base=#<Account id: 2445583175001, org_name: "Douglas-Huels", org_legaladdress: "178 Fritsch Crossroad\nEast Danielport, CT 26498-25...", created_at: "2020-06-18 08:56:51", updated_at: "2020-06-18 08:56:53", provider: true, buyer: false, country_id: nil, provider_account_id: 6, domain: "mnoyabon.preview01.3scale.net", telephone_number: nil, site_access_code: "hypnotoad", credit_card_partial_number: nil, credit_card_expires_on: nil, credit_card_auth_code: nil, master: nil, billing_address_name: "Denny Kihn", billing_address_address1: "78738 Theda Via\nKohlerberg, WA 75861", billing_address_address2: "20688 Runolfsdottir Cliff\nWisokyburgh, RI 17203-39...", billing_address_city: nil, billing_address_state: nil, billing_address_country: nil, billing_address_zip: nil, billing_address_phone: nil, org_legaladdress_cont: "", city: "", state_region: "", state: "approved", paid: false, paid_at: nil, signs_legal_terms: true, timezone: nil, delta: true, from_email: "eugenie_schroeder@friesenhuel.co.uk.e641a.example....", primary_business: nil, business_category: nil, zip: "", extra_fields: {"red_hat_account_number"=>"", "red_hat_account_verified_by"=>"", "API_Purpose_3s__c"=>"", "API_Status_3s__c"=>"", "API_Type_3s__c"=>"", "API_Onprem_3s__c"=>"", "Signup_origin"=>"", "account_type"=>"", "SFDC_Account_ID"=>"", "eval_owner"=>"", "eval_end_date"=>"", "Max-number-of-Services-Entitlement"=>"", "account-exe"=>"", "opp-number"=>""}, vat_code: nil, fiscal_code: nil, vat_rate: nil, invoice_footnote: nil, vat_zero_text: nil, default_account_plan_id: 2357356192472, default_service_id: nil, credit_card_authorize_net_payment_profile_token: nil, tenant_id: 2445583175001, self_domain: "mnoyabon-admin.preview01.3scale.net", s3_prefix: "mnoyabon", prepared_assets_version: nil, sample_data: false, proxy_configs_file_size: nil, proxy_configs_updated_at: nil, proxy_configs_content_type: nil, proxy_configs_file_name: nil, support_email: nil, finance_support_email: nil, billing_address_first_name: nil, billing_address_last_name: nil, email_all_users: true, partner_id: nil, proxy_configs_conf_file_name: nil, proxy_configs_conf_content_type: nil, proxy_configs_conf_file_size: nil, proxy_configs_conf_updated_at: nil, hosted_proxy_deployed_at: nil, po_number: "", state_changed_at: "2020-06-18 08:56:53", payment_method_id: nil>, @messages={:subdomain=>["must be a valid domain name"], :billing_address_name=>[], :billing_address_address1=>[], :billing_address_city=>[], :billing_address_country=>[]}, @details={:subdomain=>[{:error=>:invalid, :value=>"mnoyabon.preview01"}]}>
      

      This is not a blocker to test the previous problem, because I can bypass this problem by one of these 2 options:

      1. In the Rails console, do manually the updates of the tenant and its billing strategy with update_column or save(validate: false) to skip validations
      2. In the Rails console, manually change the domain string for one that our validations accept, do the other updates in the tenant and billing strategy normally (which validations), and then change back the domain string for the perceived invalid one but that works for browsing preview UI.

      We should eventually fix this.

      Extra problem: when updating a billing strategy fails, the page crashes instead of showing a nice error message. The reason is it renders the 'show' page without giving values to the instance variables that the view expects to have, and this can be fixed and cleaned by the 2 files attached (app/views/finance/provider/settings/show.html.slim & app/controllers/finance/provider/settings_controller.rb). However, this also requires adding tests and doing it all well.

            Unassigned Unassigned
            mnoyabon Marta Noya (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: