Skip to content

Make the JSON ingestion spec extension fully opt-in#1249

Open
jwils wants to merge 5 commits into
joshuaw/indexer-ingestion-adaptersfrom
joshuaw/lazy-json-ingestion-spec-default
Open

Make the JSON ingestion spec extension fully opt-in#1249
jwils wants to merge 5 commits into
joshuaw/indexer-ingestion-adaptersfrom
joshuaw/lazy-json-ingestion-spec-default

Conversation

@jwils

@jwils jwils commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Why

On #1205, @myronmarston suggested that the DEFAULT_SCHEMA_DEFINITION_EXTENSION_MODULES availability probe in spec_support/schema_definition_helpers.rb (a begin/rescue LoadError evaluated at file load) could go away in a follow-up once the extraction settled. The review here then asked the natural follow-on question: is there anything left that really needs the defaulting, or is this a good time to force tests to opt in?

Answer: nothing needs the defaulting anymore. This PR removes it entirely.

What

  • spec_support/schema_definition_helpers.rb no longer applies any extension modules by default — define_schema in specs builds a plain core schema unless the caller passes extension_modules:.
  • The places that genuinely need JSON schemas now opt in explicitly, at the level where the need exists:
    • generate_schema_artifacts includes the extension only when loading the repository's main test schema (config/schema.rb), which uses the JSON ingestion schema definition DSL. Schemas defined via a block get no extensions unless requested.
    • build_indexer includes the extension when it generates schema artifacts itself, since the indexer can only ingest JSON events today. The require is lazy so spec bundles without elasticgraph-json_ingestion (apollo, warehouse, health_check, query_interceptor) can still build an indexer from an externally built datastore_core:.
    • The camelCase acceptance run and individual specs that index documents with inline schemas pass schema_definition_extension_modules: / extension_modules: at their build call sites.
  • Vestigial t.json_schema calls in unit specs that never index are removed, along with a JsonSafeLong placeholder assertion in elasticgraph-graphql that duplicated coverage now living in elasticgraph-json_ingestion.
  • Per @myronmarston's suggestion on Migrate JSON ingestion specs into gem #1224, a gem-local "JSONIngestionSchemaDefinitionHelpers" shared context (modeled on elasticgraph-warehouse's warehouse_schema_support) now applies APIExtension to every schema defined in elasticgraph-json_ingestion's own specs, so those call sites don't each pass extension_modules: explicitly.

Verification

  • script/run_gem_specs for elasticgraph-schema_definition, elasticgraph-json_ingestion, elasticgraph-indexer, elasticgraph-graphql, elasticgraph-datastore_core, elasticgraph-admin, elasticgraph-health_check, and elasticgraph-query_interceptor
  • script/type_check
  • script/quick_build

Stack

Current PR is marked with ->.

Comment thread spec_support/spec_helper.rb Outdated
@jwils jwils force-pushed the joshuaw/indexer-ingestion-adapters branch from e8e1a67 to 1631628 Compare June 11, 2026 16:04
@jwils jwils force-pushed the joshuaw/lazy-json-ingestion-spec-default branch from 81cb325 to 5e11583 Compare June 11, 2026 16:04
@jwils jwils changed the title Load the JSON ingestion spec extension default lazily Make the JSON ingestion spec extension fully opt-in Jun 11, 2026
@jwils jwils force-pushed the joshuaw/lazy-json-ingestion-spec-default branch from 8dc35fb to 39af63e Compare June 11, 2026 17:14
@jwils jwils force-pushed the joshuaw/indexer-ingestion-adapters branch from 1631628 to 4a79422 Compare June 11, 2026 17:14
jwils added 2 commits June 11, 2026 21:33
Removes the load-time availability probe (`begin/rescue LoadError`) from
`spec_support/schema_definition_helpers.rb`, as suggested on #1205. The
`require` now happens only when a spec relies on the default extension
modules, so the file loads fine in spec bundles that exclude the optional
`elasticgraph-json_ingestion` gem (those suites pass `extension_modules:`
explicitly), and a suite that relies on the default without the gem gets a
clear `LoadError` instead of silently building artifacts without JSON
schemas. Spec files that reference the extension constant directly now
require it themselves instead of depending on the probe's load-time side
effect.
The lazy default now lives in `CommonSpecHelpers` so that
`generate_schema_artifacts` (and `build_datastore_core`, via a new
`schema_definition_extension_modules` option) can use it too. The
`elasticgraph-health_check` and `elasticgraph-query_interceptor` suites —
whose bundles exclude `elasticgraph-json_ingestion` — pass `[]` explicitly.
Spec files that reference the extension constant directly now require it
themselves rather than relying on the deleted probe's load-time side effect.
@jwils jwils force-pushed the joshuaw/indexer-ingestion-adapters branch from 4a79422 to b1abdb0 Compare June 12, 2026 02:34
jwils added 2 commits June 11, 2026 21:35
Nothing needs the defaulting anymore. The shared spec helpers no longer
apply the JSON ingestion extension to schema definitions; instead, each
place that genuinely needs JSON schemas opts in explicitly:

- `generate_schema_artifacts` includes the extension only when loading
  the repository's main test schema (`config/schema.rb`), which uses the
  JSON ingestion schema definition DSL.
- `build_indexer` includes the extension when it generates artifacts
  itself, since the indexer can only ingest JSON events today. The
  require is lazy so bundles without `elasticgraph-json_ingestion` can
  still build an indexer from an externally built `datastore_core:`.
- Specs that index documents with inline schemas (and so need JSON
  schema validation) pass the extension at their build call sites.
- Vestigial `t.json_schema` calls in unit specs that never index are
  removed, along with a `JsonSafeLong` placeholder assertion that
  duplicated coverage now living in elasticgraph-json_ingestion.
Every spec in elasticgraph-json_ingestion exercises behavior provided by
APIExtension, so a gem-local "JSONIngestionSchemaDefinitionHelpers"
context (which extends the shared "SchemaDefinitionHelpers" context)
now applies the extension to every schema its specs define, instead of
each `define_schema` call site passing `extension_modules:` explicitly.
@jwils jwils force-pushed the joshuaw/lazy-json-ingestion-spec-default branch from 39af63e to 6a733f1 Compare June 12, 2026 02:45
With `VALIDATE_GRAPHQL_SCHEMAS=1` (as on CI), the eager SDL validation
raised the unresolvable-type error during GraphQL schema generation,
before JSON schema generation could exercise the wrapped
`FieldReference#resolve` nil return the example exists to cover, leaving
that branch uncovered. Tagging the example with
`:dont_validate_graphql_schema` (the existing opt-out for intentionally
invalid schemas) makes the error surface via the JSON schema path in all
environments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants