Skip to content

Allow query_cluster: null in datastore config to hide types#1127

Merged
myronmarston merged 3 commits intoblock:mainfrom
anthonycastiglia-toast:allow-null-query-cluster-in-yaml-config
Apr 16, 2026
Merged

Allow query_cluster: null in datastore config to hide types#1127
myronmarston merged 3 commits intoblock:mainfrom
anthonycastiglia-toast:allow-null-query-cluster-in-yaml-config

Conversation

@anthonycastiglia-toast
Copy link
Copy Markdown
Contributor

Allow query_cluster: null in YAML Configuration

Issue

The hidden type spec acceptance tests specify that query_cluster: nil should hide index types from the GraphQL schema (hidden_types_spec.rb:21), and this works when modifying configs programatically as is done in the test:

config_index_def_of(query_cluster: nil) 

However, loading this configuration from YAML fails validation:

index_definitions:
  payments:
    query_cluster: null  # fails with Error: "value is not a string"

The JSON schema defines the query_cluster type as the non-nullable type: "string", even though accessible_from_queries? correctly handles nil at runtime.

Solution

Updated JSON schemas to accept ["string", "null"] and RBS signatures to ::String?. The field remains required to force explicit configuration choices.

Files changed:

  • config_schema.yaml - Allow ['string', 'null']
  • config.rb - Allow ["string", "null"]
  • index_definition.rbs - Change to ::String?
  • config_spec.rb - Add regression test

Testing

In addition to a new regression test for YAML validation with null, I've tested this locally by modifying the schema in config/settings/development.yaml:

     components: *main_index_settings
     electrical_parts: *main_index_settings
     manufacturers: *main_index_settings
-    mechanical_parts: *main_index_settings
+    mechanical_parts:
+      query_cluster: null
+      index_into_clusters: ["main"]
+      ignore_routing_values: []
+      custom_timestamp_ranges: []
+      setting_overrides:
+        number_of_shards: 1
+      setting_overrides_by_timestamp: {}
     teams: *main_index_settings
     widget_currencies: *main_index_settings
     widgets: *main_index_settings

Without the fix, starting elasticgraph locally via bundle exec boot_locally fails with

ElasticGraph::Errors::ConfigError: Invalid configuration for `ElasticGraph::DatastoreCore::Config` at `datastore`: Validation errors: (ElasticGraph::Errors::ConfigError)

{
  "data": null,
  "data_pointer": "/index_definitions/mechanical_parts/query_cluster",
  "schema_pointer": "/$defs/config/properties/index_definitions/patternProperties/.+/properties/query_cluster",
  "type": "string",
  "error": "value at `/index_definitions/mechanical_parts/query_cluster` is not a string"
}

After applying the fix, boot_locally succeeds and hides the mechanical_parts index as expected:
Screenshot 2026-04-14 at 2 17 22 PM

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 14, 2026

CLA assistant check
All committers have signed the CLA.

@anthonycastiglia-toast anthonycastiglia-toast force-pushed the allow-null-query-cluster-in-yaml-config branch from bb50ffa to bd9b1cd Compare April 14, 2026 21:39
Copy link
Copy Markdown
Collaborator

@myronmarston myronmarston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from one suggested rewording.

Comment thread elasticgraph-datastore_core/lib/elastic_graph/datastore_core/config.rb Outdated
anthonycastiglia-toast and others added 3 commits April 16, 2026 09:10
The acceptance tests demonstrate that setting `query_cluster: nil`
should hide index types from the GraphQL schema. However, loading
this configuration from YAML fails validation because the JSON schema
only accepts string values.

This commit updates the schema definitions to accept null values:
- Updated config_schema.yaml to allow ['string', 'null']
- Updated config.rb JSON schema to allow ["string", "null"]
- Updated RBS type signatures to allow String?
- Added regression test for YAML loading with null value
- Updated documentation to explain null behavior

The query_cluster field remains required to force explicit
configuration choices.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…onfig.rb

Co-authored-by: Myron Marston <myron.marston@gmail.com>
@myronmarston myronmarston force-pushed the allow-null-query-cluster-in-yaml-config branch from 356b902 to abbc1cd Compare April 16, 2026 16:10
@myronmarston myronmarston merged commit d36ef53 into block:main Apr 16, 2026
19 checks passed
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.

3 participants