{"record":{"id":"f16399187249ffe3","repo":"we-promise/sure","slug":"invalid-institution-url-for-class-name-acco","errorCode":null,"errorMessage":"Invalid institution URL for <%= class_name %> account #{provider_account.id}: #{url}","messagePattern":"Invalid institution URL for <%= class_name %> account #(.+?): #(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/generators/provider/family/templates/adapter.rb.tt","lineNumber":100,"sourceCode":"<% if investment_provider? -%>\n  def can_delete_holdings?\n    false\n  end\n<% end -%>\n\n  def institution_domain\n    metadata = provider_account.institution_metadata\n    return nil unless metadata.present?\n\n    domain = metadata[\"domain\"]\n    url = metadata[\"url\"]\n\n    # Derive domain from URL if missing\n    if domain.blank? && url.present?\n      begin\n        domain = URI.parse(url).host&.gsub(/^www\\./, \"\")\n      rescue URI::InvalidURIError\n        Rails.logger.warn(\"Invalid institution URL for <%= class_name %> account #{provider_account.id}: #{url}\")\n      end\n    end\n\n    domain\n  end\n\n  def institution_name\n    metadata = provider_account.institution_metadata\n    return nil unless metadata.present?\n\n    metadata[\"name\"] || item&.institution_name\n  end\n\n  def institution_url\n    metadata = provider_account.institution_metadata\n    return nil unless metadata.present?\n\n    metadata[\"url\"] || item&.institution_url","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/lib/generators/provider/family/templates/adapter.rb.tt#L82-L118","documentation":"In the generated provider adapter, institution_domain reads institution_metadata and, when the \"domain\" key is blank but \"url\" is present, tries URI.parse(url).host to derive the domain (stripping a leading www.). URI::InvalidURIError is rescued with this warning, leaving domain nil, which only degrades institution logo/website lookups. This is a template file — the warning text literally contains <%= class_name %> until the generator renders it.","triggerScenarios":"institution_metadata[\"url\"] is a malformed URI that raises URI::InvalidURIError: strings with spaces (\"http://my bank.com\"), missing scheme with bad characters (\"mybank com\"), placeholder text (\"Not Available\"), or control characters. Note: URI.parse(\"mybank.com\") does not raise (host is nil), so the warning fires only for genuinely unparseable strings.","commonSituations":"Aggregator institution metadata containing display text instead of URLs; manually curated/free-text institution fields; providers that fill the url slot with a null-like sentinel (\"N/A\", \"-\"); encoding issues in copied URLs.","solutions":["Inspect provider_account.institution_metadata to see the exact url value that failed to parse","Prefer populating the \"domain\" key in institution_metadata directly (in the generated extract_institution_metadata) so URL parsing is never needed","Harden the generated adapter: rescue and retry with a cleaned string, or fall back to a regex host extraction","Accept nil domain when the institution has no usable website"],"exampleFix":"# generated adapter - before\nbegin\n  domain = URI.parse(url).host&.gsub(/^www\\./, \"\")\nrescue URI::InvalidURIError\n  Rails.logger.warn(\"Invalid institution URL for #{provider_account.id}: #{url}\")\nend\n\n# after\nbegin\n  domain = URI.parse(url.to_s.strip).host&.gsub(/^www\\./, \"\")\n  domain ||= url.to_s[/\\b(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z]{2,}\\b/i]\nrescue URI::InvalidURIError\n  domain = url.to_s[/\\b(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z]{2,}\\b/i]\n  Rails.logger.warn(\"Invalid institution URL for #{provider_account.id}: #{url}\") if domain.nil?\nend","handlingStrategy":"try-catch","validationCode":"# Cheap pre-check before URI.parse in the generated adapter\ndef parseable_url?(url)\n  url.is_a?(String) && url.strip.match?(%r{\\Ahttps?://\\S+\\z})\nend\n\ndomain = parseable_url?(url) ? URI.parse(url.strip).host&.gsub(/^www\\./, \"\") : nil","typeGuard":"def plausible_url?(value)\n  value.is_a?(String) && value.strip.match?(%r{\\Ahttps?://[\\w.-]+\\.[a-z]{2,}(?:/\\S*)?\\z}i)\nend","tryCatchPattern":"begin\n  domain = URI.parse(url.to_s.strip).host&.gsub(/^www\\./, \"\")\nrescue URI::InvalidURIError => e\n  Rails.logger.warn(\"Invalid institution URL for #{provider_account.id}: #{url}\")\n  domain = nil # explicit degradation, logo lookup simply skipped\nend","preventionTips":["Store institution domain directly in metadata when the provider offers it, so URL parsing is a last resort","Sanitize free-text institution fields (strip, scheme-check) before persisting them as url","Add specs with pathological urls (spaces, 'N/A', no scheme) for generated adapters"],"tags":["uri-parsing","institution-metadata","provider-data","generator-template","rescue"],"backgroundTag":"invalid-url-format","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}