Skip to content

Error thrown for enterprise connection with no domains configured #2749

@ksapchuk

Description

@ksapchuk

Checklist

  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

The same issue #2733 still occurs after the change #2736.

matchConnection in src/connection/enterprise.js throws a TypeError when an enterprise connection has no domains configured.

Uncaught TypeError: Cannot read properties of undefined (reading 'contains')

The logic needs to handle the domains value being undefined. The List() value applies only if domains property is missing, not if it's undefined.

export function matchConnection(m, email, strategies = []) {
  const target = emailDomain(email);
  if (!target) return false;
  return l.connections(m, 'enterprise', ...strategies).find(x => {
    return x.get('domains', List()).contains(target);
  });
}

Reproduction

  1. Configure an enterprise connection (e.g. samlp or oidc) with no domain entries.
  2. Initialize Lock as part of a third party client auth flow.
  3. Type any email address into the email field.
  4. Observe TypeError: Cannot read properties of undefined (reading 'contains') thrown from matchConnection.

Additional context

We are running into this issue as part a third party client auth flow for our MCP server https://auth0.com/ai/docs/mcp/get-started/authorization-for-your-mcp-server

Lock version

14.2.5

Which browsers have you tested in?

Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis points to a verified bug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions