Repository navigation
Description
Describe the bug
Every in-place update of elasticstack_elasticsearch_inference_endpoint fails on Elasticsearch 9.5.0 and later, for example rotating api_key or changing task_settings.
The provider sends the complete service_settings object to the Inference Update API. Since 9.5.0 Elasticsearch rejects an update request that contains service settings it cannot update in place (such as model_id or url), so the request fails with a 400 and nothing is changed.
On earlier versions the same request is accepted, but settings that cannot be updated are silently ignored. Changing model_id in place leaves the endpoint on the old model while the Terraform state records the new one.
To Reproduce
-
Elasticsearch 9.5.x with
xpack.inference.skip_validate_and_start: true(the setting the acceptance tests use, so no real OpenAI key is needed), and this configuration:variable "api_key" { type = string sensitive = true } resource "elasticstack_elasticsearch_inference_endpoint" "test" { inference_id = "update-repro" task_type = "completion" service = "openai" service_settings = jsonencode({ api_key = var.api_key model_id = "gpt-4o" }) }
-
terraform apply -var api_key=test-key-1, thenterraform apply -var api_key=test-key-2. -
The second apply plans an in-place update and fails:
Error: Unable to update inference endpoint with elasticstack_elasticsearch_inference_endpoint.test, status: 400, failed: [status_exception], reason: Configuration contains settings [{model_id=gpt-4o}] unknown to the [openai] service
Expected behavior
The key is updated in place. Elasticsearch accepts an update that contains only the changed setting: on 9.5.6, PUT _inference/completion/update-repro/_update with {"service_settings":{"api_key":"..."}} succeeds once the service accepts the new key.
Debug output
The error above is the complete diagnostic. The request body the provider sends is the planned service_settings as a whole:
{"service_settings":{"api_key":"test-key-2","model_id":"gpt-4o"}}Versions (please complete the following information):
- OS: macOS (arm64)
- Terraform Version: 1.6.6
- Provider version:
mainat 33e042f (nightlyv0.0.0-20261202-33e042f) - Elasticsearch Version: 9.5.6 (fails). 9.4.2 accepts the request and ignores the settings it cannot update.
Additional context
Where it comes from:
UpdateInferenceEndpointininternal/clients/elasticsearch/inference.gocopies the whole plannedservice_settingsinto the request body, andtoUpdateModelininternal/elasticsearch/inference/inferenceendpoint/models.goistoAPIModel.- Elasticsearch 9.5.0 added a check to the update action (
TransportUpdateInferenceModelAction.validateConsumedUpdateSettings) that rejects every service setting the service's update parser did not consume. Theopenaiupdate parser reads settings such asorganization_id,max_input_tokensandrate_limit, but notmodel_idorurl. The same release madeapi_keyoptional in an update. - Before 9.5.0 (checked on 9.4.2; the check is also absent from the 8.19 sources),
service_settingsin an update had to containapi_key, and other keys were ignored.
So 9.5.0 and later need only the changed keys, while earlier versions need the complete object.
What I measured with direct _update requests against an openai completion endpoint (the endpoint used a local OpenAI-compatible mock as url, so that validation calls succeed):
_update request body |
9.4.2 | 9.5.6 |
|---|---|---|
all of service_settings, api_key changed (what the provider sends) |
200 | 400, settings unknown to the service |
only api_key |
200 | 200 |
all of service_settings, model_id changed |
200, model_id unchanged on the endpoint |
400, settings unknown to the service |
only model_id |
400, api_key required |
400, settings unknown to the service |
only rate_limit |
not tested | 200 |
only task_settings |
200 | 200 |
task_settings and all of service_settings (what the provider sends when only task_settings changes) |
200 | 400, settings unknown to the service |
Why the acceptance tests do not catch it: every step that updates an endpoint has SkipFunc: skipIfUsingFakeAPIKey, because Elasticsearch validates an update against the service even when xpack.inference.skip_validate_and_start is set (checked on 9.5.6), and CI runs with the fake key. The update test configuration also changes model_id, which Elasticsearch cannot update in place.
I have a fix in progress and will open a pull request for it.
Activity
github-actions commentedon Dec 2, 2026
Thanks for the bug report! I have added the
needs-reproductionlabel to this issue.This looks like a reproducible bug, so it has been queued for the reproducer-factory pipeline. Reproducer-factory will attempt to confirm the behaviour and create a minimal reproduction case.
If this has been misclassified or there is additional context, please leave a comment on this issue so a maintainer can adjust the label manually.