we-promise/sure · warning · EnableBankingError

not_found

not_found

Error message

Resource not found

What it means

Raised by Provider::EnableBanking#handle_response on HTTP 404: the referenced session or account does not exist (anymore). The most common real cause is PSD2 consent expiry — sessions die when the bank consent ends (typically 90 days, matching maximum_consent_validity) — so a previously working session_id or account uid starts 404ing.

Source

Thrown at app/models/provider/enable_banking.rb:291

        "Accept" => "application/json"
      }
    end

    def handle_response(response)
      case response.code
      when 200, 201
        parse_response_body(response)
      when 204
        {}
      when 400
        response_data = parse_error_response_body(response)
        raise EnableBankingError.new("Bad request to Enable Banking API: #{response.body}", :bad_request, response_data: response_data)
      when 401
        raise EnableBankingError.new("Invalid credentials or expired JWT", :unauthorized)
      when 403
        raise EnableBankingError.new("Access forbidden - check your application permissions", :access_forbidden)
      when 404
        raise EnableBankingError.new("Resource not found", :not_found)
      when 408
        raise EnableBankingError.new("Request timeout from Enable Banking API", :timeout)
      when 422
        response_data = parse_response_body(response)
        raise EnableBankingError.new("Validation error from Enable Banking API: #{response.body}", :validation_error, response_data: response_data)
      when 429
        raise EnableBankingError.new("Rate limit exceeded. Please try again later.", :rate_limited)
      else
        response_data = parse_error_response_body(response)
        raise EnableBankingError.new("Failed to fetch data: #{response.code} #{response.message} - #{response.body}", :fetch_failed, response_data: response_data)
      end
    end

    def parse_error_response_body(response)
      return {} if response.body.blank?

      JSON.parse(response.body, symbolize_names: true)
    rescue JSON::ParserError

View on GitHub (pinned to e69894adb9)

Solutions

  1. Treat it as terminal for the connection: mark the linked account as needing re-authorization and stop retrying the sync
  2. Distinguish from :request_failed — 404 means the API answered 'gone', not that the network failed
  3. Verify the session_id/account uid values being passed match what create_session/get_session originally returned
  4. Track consent expiry (access.valid_until negotiated at start_authorization) and prompt re-auth before the 404s start

Example fix

# before
txns = client.get_account_transactions(account_id: uid, date_from: from)

# after
begin
  txns = client.get_account_transactions(account_id: uid, date_from: from)
rescue Provider::EnableBanking::EnableBankingError => e
  raise unless e.error_type == :not_found
  connection.update!(status: "reauth_required")
  txns = { transactions: [] }
end
Defensive patterns

Strategy: fallback

Validate before calling

def eb_session_alive?(client, session_id)
  client.get_session(session_id: session_id) && true
rescue Provider::EnableBanking::EnableBankingError => e
  e.error_type != :not_found
end

Type guard

def eb_not_found?(error)
  error.is_a?(Provider::EnableBanking::EnableBankingError) && error.error_type == :not_found
end

Try / catch

begin
  txns = client.get_account_transactions(account_id: uid, date_from: from)
rescue Provider::EnableBanking::EnableBankingError => e
  raise unless e.error_type == :not_found
  connection.update!(status: "reauth_required") # consent expired/revoked — no retry
  txns = { transactions: [] }
end

Prevention

When it happens

Trigger: get_session/get_account_details/get_account_balances/get_account_transactions called with a session whose consent expired or was revoked at the bank; a session deleted via delete_session; a mistyped account uid or one from another environment.

Common situations: Syncs scheduled past the 90-day consent window, users revoking consent at their bank, stale connection records surviving after disconnect.

Related errors


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