{"record":{"id":"74b6f43d952c77a5","repo":"forem/forem","slug":"lead-form-not-found","errorCode":null,"errorMessage":"Lead form not found","messagePattern":"Lead form not found","errorType":"exception","errorClass":"StandardError","httpStatus":null,"severity":"error","filePath":"app/liquid_tags/org_lead_form_tag.rb","lineNumber":9,"sourceCode":"class OrgLeadFormTag < LiquidTagBase\n  PARTIAL = \"liquids/org_lead_form\".freeze\n  VALID_CONTEXTS = %w[Organization].freeze\n\n  def initialize(_tag_name, input, _parse_context)\n    super\n    @form_id = parse_form_id(input)\n    @form = OrganizationLeadForm.find_by(id: @form_id)\n    raise StandardError, I18n.t(\"liquid_tags.org_lead_form_tag.not_found\") unless @form\n    raise StandardError, I18n.t(\"liquid_tags.org_lead_form_tag.inactive\") unless @form.active?\n\n    source = parse_context.partial_options[:source]\n    unless @form.organization_id == source.id\n      raise StandardError, I18n.t(\"liquid_tags.org_lead_form_tag.wrong_organization\")\n    end\n  end\n\n  def render(_context)\n    ApplicationController.render(\n      partial: PARTIAL,\n      locals: { form: @form },\n    )\n  end\n\n  private\n\n  def parse_form_id(input)","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/forem/forem/blob/f354c376a7c5d1330dc40d66f150be8d1289020d/app/liquid_tags/org_lead_form_tag.rb#L1-L27","documentation":"Forem's {% org_lead_form ID %} Liquid tag embeds an organization lead-capture form. During Liquid parsing it loads the record with OrganizationLeadForm.find_by(id:) and raises immediately when the lookup returns nil, before the active? and ownership checks run. Because Liquid tags initialize while markdown is processed, this surfaces as a liquid tag validation error when the containing page markdown is saved, previewed, or rendered.","triggerScenarios":"Embedding {% org_lead_form 123 %} where no organization_lead_forms row with id=123 exists in the current database: the form was deleted, the ID is mistyped, or the ID was copied from another environment (staging ID used on production).","commonSituations":"Org page markdown copied between environments whose databases hold different form IDs; an org admin deletes a lead form while pages still embed it; test suites hard-coding form IDs instead of using factories.","solutions":["Run OrganizationLeadForm.find_by(id: 123) in a rails console against the same database the markdown renders with; if it returns nil, the ID is wrong for this environment","Get the correct ID from the owning organization's lead form settings and update the tag to {% org_lead_form <real_id> %}","If the form was deleted, create a new lead form in that organization and replace the old ID in every page that embedded it","In tests, build the form with create(:organization_lead_form, organization: org) and interpolate form.id into the markdown instead of hard-coding"],"exampleFix":"// before\n{% org_lead_form 999 %}   <!-- no form 999 in this database -->\n\n// after\n{% org_lead_form 42 %}    <!-- existing form in this org -->","handlingStrategy":"validation","validationCode":"form = OrganizationLeadForm.find_by(id: form_id)\nfail 'form not found' unless form\nfail 'form inactive' unless form.active?\nfail 'wrong organization' unless form.organization_id == org.id\n# only now embed {% org_lead_form #{form_id} %}","typeGuard":null,"tryCatchPattern":"begin\n  Liquid::Template.parse(body_markdown)\nrescue StandardError => e\n  # e.message is already the localized user-facing text\n  errors.add(:body_markdown, \"Liquid tag error: #{e.message}\")\nend","preventionTips":["Resolve the form ID in the target environment's console before embedding","Grep stored markdown for 'org_lead_form' before deleting or renumbering lead forms","In specs, factory-create the lead form and interpolate its id"],"tags":["liquid","forem","lead-form","record-not-found","content-authoring"],"backgroundTag":"entity-not-found","analyzedSha":"f354c376a7c5d1330dc40d66f150be8d1289020d","analyzedAt":"2026-08-21T12:43:44.428Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}