async def _validate_auth_fields(
        self, db: AsyncSession, source_short_name: str, auth_fields: Optional[Dict[str, Any]]
    ) -> dict:
        """Validate auth fields based on auth type.

        Only works for config_class auth type.

        Args:
            db: The database session
            source_short_name: The short name of the source
            auth_fields: The auth fields to validate

        Returns:
            The validated auth fields as a dict

        Raises:
            HTTPException: If auth fields are invalid or not supported
        """
        # Get the source info
        source = await crud.source.get_by_short_name(db, short_name=source_short_name)
        if not source:
            raise HTTPException(status_code=404, detail=f"Source '{source_short_name}' not found")

        BASE_ERROR_MESSAGE = (
            f"See https://docs.airweave.ai/docs/connectors/{source.short_name}#authentication "
            f"for more information."
        )

        # Check if auth_config_class is defined for the source
        if not source.auth_config_class:
            raise HTTPException(
                status_code=422,
                detail=f"Source {source.name} does not have an auth configuration defined. "
                + BASE_ERROR_MESSAGE,
            )

        if auth_fields is None:
            raise HTTPException(
                status_code=422,
                detail=f"Source {source.name} requires auth fields. " + BASE_ERROR_MESSAGE,
            )

        # Create and validate auth config
        try:
            auth_config_class = resource_locator.get_auth_config(source.auth_config_class)
            auth_config = auth_config_class(**auth_fields)
            return auth_config.model_dump()
        except Exception as e:
            source_connection_logger.error(f"Failed to validate auth fields: {e}")

            # Check if it's a Pydantic validation error and format it nicely
            from pydantic import ValidationError

            if isinstance(e, ValidationError):
                # Extract the field names and error messages
                error_messages = []
                for error in e.errors():
                    field = ".".join(str(loc) for loc in error.get("loc", []))
                    msg = error.get("msg", "")
                    error_messages.append(f"Field '{field}': {msg}")

                error_detail = (
                    f"Invalid configuration for {source.auth_config_class}:\n"
                    + "\n".join(error_messages)
                )
                raise HTTPException(
                    status_code=422,
                    detail=f"Invalid auth fields: {error_detail}. " + BASE_ERROR_MESSAGE,
                ) from e
            else:
                # For other types of errors
                raise HTTPException(
                    status_code=422,
                    detail=f"Invalid auth fields: {str(e)}. " + BASE_ERROR_MESSAGE,
                ) from e
Validate auth fields based on auth type.

        Only works for config_class auth type.

        Args:
            db: The database session
            source_short_name: The short name of the source
            auth_fields: The auth fields to validate

        Returns:
            The validated auth fields as a dict

        Raises:
            HTTPException: If auth fields are invalid or not supported
        
backend/airweave/core/source_connection_service.py