Skip to content

[Bug] elasticstack_elasticsearch_inference_endpoint: in-place updates fail with 400 on Elasticsearch 9.5+ #5546

Backlog

Description

@aydasraf

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

  1. 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"
      })
    }
  2. terraform apply -var api_key=test-key-1, then terraform apply -var api_key=test-key-2.

  3. 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: main at 33e042f (nightly v0.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:

  • UpdateInferenceEndpoint in internal/clients/elasticsearch/inference.go copies the whole planned service_settings into the request body, and toUpdateModel in internal/elasticsearch/inference/inferenceendpoint/models.go is toAPIModel.
  • 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. The openai update parser reads settings such as organization_id, max_input_tokens and rate_limit, but not model_id or url. The same release made api_key optional in an update.
  • Before 9.5.0 (checked on 9.4.2; the check is also absent from the 8.19 sources), service_settings in an update had to contain api_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

  1. added
    needs-reproduction
    triaged
    on Dec 2, 2026
  2. github-actions commented on Dec 2, 2026

    @github-actions
    Contributor

    Thanks for the bug report! I have added the needs-reproduction label 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.

  3. added
    bug
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-reproductiontriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions