Skip to content

Commit df526fc

Browse files
committed
Load the example scalar coercion adapter from a consistent path
The extension loader raises if the same extension constant is loaded from two different `require_path`s within one process. `scalar_type_extension_spec` loaded `ExampleScalarCoercionAdapter` via an absolute path while `elasticgraph-schema_definition`'s `scalar_types_by_name_spec` used a relative one, so any spec worker that ran both files failed 17 examples with `InvalidExtensionError`. Use the same relative path (with a local copy of the example adapter so the gem's own suite can resolve it).
1 parent 1c79f46 commit df526fc

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 - 2026 Block, Inc.
2+
#
3+
# Use of this source code is governed by an MIT-style
4+
# license that can be found in the LICENSE file or at
5+
# https://opensource.org/licenses/MIT.
6+
#
7+
# frozen_string_literal: true
8+
9+
class ExampleScalarCoercionAdapter
10+
def self.coerce_input(value, ctx)
11+
end
12+
13+
def self.coerce_result(value, ctx)
14+
end
15+
end

elasticgraph-json_ingestion/spec/unit/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ def grouping_missing_value_placeholder_for(mapping_type, **json_schema_options)
9494
end
9595

9696
def scalar_coercion_adapter_path
97-
::File.join(CommonSpecHelpers::REPO_ROOT, "elasticgraph-schema_definition/spec/support/example_extensions/scalar_coercion_adapter")
97+
# Must match the `defined_at` path used by other specs (e.g. in `elasticgraph-schema_definition`)
98+
# that load this adapter: the extension loader raises if the same extension is loaded from two
99+
# different paths within one process, as can happen when one worker runs both suites.
100+
"support/example_extensions/scalar_coercion_adapter"
98101
end
99102

100103
def build_api

0 commit comments

Comments
 (0)