Skip to content

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

Open
anthonycastiglia-toast wants to merge 3 commits intoblock:mainfrom
anthonycastiglia-toast:allow-null-query-cluster-in-yaml-config
Open

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

Conversation

@anthonycastiglia-toast
Copy link
Copy Markdown

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

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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>
@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 2 commits April 15, 2026 07:31
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