we-promise/sure · warning

<%= class_name %>ConnectionCleanupJob - API delete failed: #

Error message

<%= class_name %>ConnectionCleanupJob - API delete failed: #{e.message}

What it means

Generated delete_connection currently resolves the item's provider and credentials and then returns nil — the actual provider API call is a commented TODO example. The rescue only catches errors raised while resolving provider/credentials or by partially enabling the example call (e.g. NoMethodError because provider.delete_connection is not implemented on the SDK). Logged as a warning and swallowed, so the job completes with no remote deletion performed.

Source

Thrown at lib/generators/provider/family/templates/connection_cleanup_job.rb.tt:52

  private

    def delete_connection(<%= file_name %>_item, authorization_id)
      provider = <%= file_name %>_item.<%= file_name %>_provider
      return unless provider

      credentials = <%= file_name %>_item.<%= file_name %>_credentials
      return unless credentials

      # TODO: Implement API call to delete connection
      # Example:
      # provider.delete_connection(
      #   authorization_id: authorization_id,
      #   **credentials
      # )
      nil # Placeholder until provider.delete_connection is implemented
    rescue => e
      Rails.logger.warn(
        "<%= class_name %>ConnectionCleanupJob - API delete failed: #{e.message}"
      )
    end
<% else -%>

  def perform(<%= file_name %>_item_id:, account_id:)
    Rails.logger.info(
      "<%= class_name %>ConnectionCleanupJob - Cleaning up for former account #{account_id}"
    )

    <%= file_name %>_item = <%= class_name %>Item.find_by(id: <%= file_name %>_item_id)
    return unless <%= file_name %>_item

    # For banking providers, cleanup is typically simpler since there's no
    # separate authorization concept - the item itself holds the credentials.
    # Override this method if your provider needs specific cleanup logic.

    Rails.logger.info("<%= class_name %>ConnectionCleanupJob - Cleanup complete for account #{account_id}")

View on GitHub (pinned to e69894adb9)

Solutions

  1. Implement delete_connection(authorization_id:, **credentials) on the provider SDK, or leave the placeholder and accept that connections are only removed locally
  2. Match the call site to the real SDK signature — the example expects keyword args authorization_id plus splatted credentials
  3. Verify <%= file_name %>_item.<%= file_name %>_credentials actually returns the credential hash expected by the SDK
  4. Re-enqueue the cleanup job after fixing to remove the orphaned provider connection

Example fix

# generated connection_cleanup_job.rb - before (TODO placeholder)
# provider.delete_connection(
#   authorization_id: authorization_id,
#   **credentials
# )
nil # Placeholder

# after
def delete_connection(<%= file_name %>_item, authorization_id)
  provider = <%= file_name %>_item.<%= file_name %>_provider
  return unless provider

  credentials = <%= file_name %>_item.<%= file_name %>_credentials
  return unless credentials

  provider.delete_connection(
    authorization_id: authorization_id,
    **credentials
  )
rescue => e
  Rails.logger.warn("<%= class_name %>ConnectionCleanupJob - API delete failed: #{e.message}")
end
Defensive patterns

Strategy: try-catch

Validate before calling

# Resolve SDK pieces explicitly and verify the method exists before calling
provider = <%= file_name %>_item.<%= file_name %>_provider
credentials = <%= file_name %>_item.<%= file_name %>_credentials
if provider.nil? || credentials.nil?
  Rails.logger.info("<%= class_name %>ConnectionCleanupJob - nothing to delete (provider or credentials missing)")
  return
end
unless provider.respond_to?(:delete_connection)
  Rails.logger.warn("<%= class_name %>ConnectionCleanupJob - SDK lacks delete_connection; skipping API delete")
  return
end

Try / catch

rescue NoMethodError => e
  Rails.logger.warn("<%= class_name %>ConnectionCleanupJob - SDK interface missing: #{e.message} - implement delete_connection")
rescue => e
  Rails.logger.warn("<%= class_name %>ConnectionCleanupJob - API delete failed: #{e.class} #{e.message}")
end

Prevention

When it happens

Trigger: Uncommenting the example provider.delete_connection(authorization_id:, **credentials) call before that method exists on the provider SDK class; credentials record present but raising on attribute access; provider resolution returning an object without the expected interface (connection_cleanup_job.rb.tt:52 region).

Common situations: Developers scaffolding a new provider with the generator and wiring the TODO incrementally; SDK method renamed or signature changed so **credentials splat raises ArgumentError.

Related errors


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