{"record":{"id":"5849b33d3dec323f","repo":"antiwork/gumroad","slug":"changing-plans-for-fixed-length-subscriptions-is-n","errorCode":null,"errorMessage":"Changing plans for fixed-length subscriptions is not currently supported.","messagePattern":"Changing plans for fixed-length subscriptions is not currently supported\\.","errorType":"exception","errorClass":"Subscription::UpdateFailed","httpStatus":null,"severity":"error","filePath":"app/models/subscription.rb","lineNumber":1033,"sourceCode":"  end\n\n  def end_subscription!\n    with_lock do\n      return if ended_at.present?\n\n      self.ended_at = Time.current\n      self.deactivate!\n\n      CustomerLowPriorityMailer.subscription_ended(id).deliver_later(queue: \"low\")\n      ContactingCreatorMailer.subscription_ended(id).deliver_later(queue: \"critical\") if seller.enable_payment_email?\n    end\n  end\n\n  # creates a new original subscription purchase & archives the existing one.\n  # Any changes to the subscription made here must be reverted in `Subscription::UpdaterService#restore_original_purchase`\n  def update_current_plan!(new_variants:, new_price:, new_quantity: nil, perceived_price_cents: nil, is_applying_plan_change: false, skip_preparing_for_charge: false, offer_code: nil, clear_discount: false, clear_deleted_discount: false, authenticated_offer_code_buyer: AUTHENTICATED_OFFER_CODE_BUYER_NOT_PROVIDED, submitted_pre_discount_price_cents: nil, once_per_cart_discount_allocation: nil)\n    raise Subscription::UpdateFailed, \"Installment plans cannot be updated.\" if is_installment_plan?\n    raise Subscription::UpdateFailed, \"Changing plans for fixed-length subscriptions is not currently supported.\" if has_fixed_length?\n\n    ActiveRecord::Base.transaction do\n      payment_option = last_payment_option\n\n      # build new original subscription purchase\n      new_purchase = build_purchase(override_params: { is_original_subscription_purchase: true,\n                                                       email: original_purchase.email,\n                                                       is_free_trial_purchase: original_purchase.is_free_trial_purchase },\n                                    authenticated_offer_code_buyer:)\n      # avoid failing `Purchase#variants_available` validation if reverting back to the original set of variants & those variants are unavailable\n      new_purchase.original_variant_attributes = original_purchase.variant_attributes\n      # avoid failing `Purchase#price_not_too_low` validation if reverting back to the original subscription price & price has been deleted\n      new_purchase.original_price = price\n      # avoid `Purchase#not_double_charged` and sold out validations\n      new_purchase.is_updated_original_subscription_purchase = true\n      # avoid price validation failures when applying a pre-existing plan change (i.e. a downgrade)\n      new_purchase.is_applying_plan_change = is_applying_plan_change\n      # avoid preparing chargeable, in cases where we simply want to calculate the new price","sourceCodeStart":1015,"sourceCodeEnd":1051,"githubUrl":"https://github.com/antiwork/gumroad/blob/afeacbd394069a1cbf0c6c50ee8e900925050370/app/models/subscription.rb#L1015-L1051","documentation":"Raised as Subscription::UpdateFailed by Subscription#update_current_plan! when the subscription has_fixed_length? — fixed-length subscriptions (e.g. 6-month memberships) do not support plan migration. Like the installment-plan check, it fires before the transaction that would build a new original purchase and archive the existing one, so no partial state is written.","triggerScenarios":"Calling update_current_plan! (plan change, tier change, or price-change flows including ScheduleMembershipPriceUpdatesJob sweeps) on a subscription created with a fixed length/term.","commonSituations":"Sellers with mixed recurring + fixed-length products running blanket price updates; customers on fixed-length memberships attempting to switch tiers mid-term; automated plan-migration tooling not filtering on has_fixed_length?.","solutions":["Exclude fixed-length subscriptions from plan-change flows: check subscription.has_fixed_length? first and skip or offer cancel-and-repurchase.","If the product must support plan changes, recreate it as an open-ended recurring product.","Rescue Subscription::UpdateFailed in jobs (as UpdaterService/RecurringChargeWorker already do) and log it for follow-up."],"exampleFix":"# before\nsubscription.update_current_plan!(new_variants:, new_price:) # Subscription::UpdateFailed\n\n# after\nif subscription.has_fixed_length?\n  return { error: \"Changing plans for fixed-length subscriptions is not currently supported.\" }\nend\nsubscription.update_current_plan!(new_variants:, new_price:)","handlingStrategy":"try-catch","validationCode":"return { unsupported: true } if subscription.has_fixed_length?","typeGuard":null,"tryCatchPattern":"begin\n  subscription.update_current_plan!(new_variants:, new_price:)\nrescue Subscription::UpdateFailed => e\n  log_and_report(e) # fixed-length subscriptions don't support plan migration\nend","preventionTips":["Exclude has_fixed_length? subscriptions from tier/plan change features and bulk price updates.","If plan changes are a product requirement, use open-ended recurring products instead of fixed length.","The raise happens before the transaction — safe to catch without cleanup."],"tags":["subscriptions","fixed-length","plan-change","rails","updatefailed"],"backgroundTag":"unsupported-plan-change","analyzedSha":"afeacbd394069a1cbf0c6c50ee8e900925050370","analyzedAt":"2026-08-21T17:58:52.159Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}