From 8bb1dbb20332aa6f99704a11171a155fce930608 Mon Sep 17 00:00:00 2001 From: Sergio Bobillier Date: Wed, 18 Feb 2026 16:01:53 +0100 Subject: [PATCH] [BUGFIX] Fix NameError when requiring the Client class Fixes a NameError that occurred when requiring 'jay_api/elasticsearch/client' without requiring 'elasticsearch'. The error was happening because of two things: 1. The class's file was requiring 'elasticsearch/api/namespace/tasks', however, this file was not only not needed by the class but it cannot be directly required, because it tries to use Elasticsearch's Common::Client class without requiring it first, hence the NameError. 2. Requiring 'elasticsearch/transport/transport/errors', which is actually needed by the class, causes a NameError because it tries to use Timeout::Error without requiring 'timeout' first. So, to fix the issue a require statement for 'timeout' is being added. This error was only happening when the class was required directly, so it is mostly visible in unit tests. --- CHANGELOG.md | 2 ++ lib/jay_api/elasticsearch/client.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b66d31..a4825b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Please mark backwards incompatible changes with an exclamation mark at the start ## [Unreleased] ### Fixed +- A `NameError` that was being raised when `jay_api/elasticsearch/client` was + required without requiring `elasticsearch`. - A `NoMethodError` that was being raised by `Elasticsearch::Stats::Indices` when `active_support/core_ext/string` hadn't been loaded. diff --git a/lib/jay_api/elasticsearch/client.rb b/lib/jay_api/elasticsearch/client.rb index 2507557..366d559 100644 --- a/lib/jay_api/elasticsearch/client.rb +++ b/lib/jay_api/elasticsearch/client.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'elasticsearch/api/namespace/tasks' +require 'timeout' require 'elasticsearch/transport/transport/errors' require 'faraday/error' require 'forwardable'