Skip to content

Add validation to service settings update method#140082

Closed
Jan-Kazlouski-elastic wants to merge 53 commits intoelastic:mainfrom
Jan-Kazlouski-elastic:add-validation-to-service-settings-update-method
Closed

Add validation to service settings update method#140082
Jan-Kazlouski-elastic wants to merge 53 commits intoelastic:mainfrom
Jan-Kazlouski-elastic:add-validation-to-service-settings-update-method

Conversation

@Jan-Kazlouski-elastic
Copy link
Copy Markdown
Contributor

@Jan-Kazlouski-elastic Jan-Kazlouski-elastic commented Dec 30, 2025

This PR is related to: #122356
Currently Service Settings updateServiceSettings method that is called during endpoint update operation is implemented only for GoogleVertexAiEmbeddingsServiceSettings and ElasticsearchInternalServiceSettings. This PR introduces implementations for some part of ServiceSettings classes while keeping default implementation in ServiceSettings interface returning unchanged this instance. This is done to unlock update functionality the inference services.
CustomServiceSettings require taskType parameter so it was added to the method signature.

updateServiceSettings method kept the same for:

  1. MinimalServiceSettings
  2. SageMakerStoredServiceSchema's NO_OP implementation
    I ask for reviewer's attention to this.

Some refactoring was also done both to ServiceSettings classes and test classes.
Issue with treating update operation as operation done only with PERSISTENT context is fixed by using REQUEST context in Service classes.

  • - Have you signed the contributor license agreement?
  • - Have you followed the contributor guidelines?
  • - If submitting code, have you built your formula locally prior to submission with gradle check?
  • - If submitting code, is your pull request against main? Unless there is a good reason otherwise, we prefer pull requests against main and will backport as needed.
  • - If submitting code, have you checked that your submission is for an OS and architecture that we support?
  • - If you are submitting this code for a class then read our policy for that.

@elasticsearchmachine elasticsearchmachine added v9.4.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Dec 30, 2025
@Jan-Kazlouski-elastic Jan-Kazlouski-elastic marked this pull request as ready for review December 30, 2025 21:36
@elasticsearchmachine elasticsearchmachine added the needs:triage Requires assignment of a team area label label Dec 30, 2025
@PeteGillinElastic PeteGillinElastic added the :SearchOrg/Inference Label for the Search Inference team label Jan 5, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/search-inference-team (Team:Search - Inference)

@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Jan 5, 2026
…vice-settings-update-method

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/contextualai/rerank/ContextualAiRerankServiceSettings.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/jinaai/JinaAIServiceSettings.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/voyageai/VoyageAIServiceSettings.java
@Jan-Kazlouski-elastic Jan-Kazlouski-elastic marked this pull request as draft January 7, 2026 17:37
Jan-Kazlouski-elastic and others added 9 commits January 7, 2026 20:24
…gs-update-method' into add-validation-to-service-settings-update-method
…vice-settings-update-method

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportUpdateInferenceModelAction.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/deepseek/DeepSeekChatCompletionModel.java
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ai21/completion/Ai21ChatCompletionServiceSettingsTests.java
Copy link
Copy Markdown
Contributor

@DonalEvans DonalEvans left a comment

Choose a reason for hiding this comment

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

I got a little way into reviewing this and realized that my comment about only allowing certain fields to be updated will require extensive changes, so I'm submitting this review before looking at all of the other files to allow you to make a start on the changes.

@@ -177,7 +177,7 @@ protected void masterOperation(
})
.<ModelConfigurations>andThen((listener, didUpdate) -> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I should have thought of this when reviewing the earlier PR, but do you think it would be worthwhile to put in a check after line 166 in this file that if the merged model is equal to the parsed model, then we return early? If the update is a no-op then we don't need to do the extra work of performing a validation call or updating the indices.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Stakes of actually performing the validation and update on not updated model are higher than in case described in your previous comment and I agree that we should return early. Specially considering the fact it is so easy to implement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This change is done. Also in #142597

Comment on lines +88 to +93
var extractedModelId = extractOptionalString(
serviceSettings,
ServiceFields.MODEL_ID,
ModelConfigurations.SERVICE_SETTINGS,
validationException
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we want to allow modelId to be updated. I don't think there's really a valid use case for changing the model associated with an endpoint, since doing so will cause the behaviour of the endpoint to change, and the InferenceServiceConfiguration in Ai21Service lists it as not updatable:

                configurationMap.put(
                    ServiceFields.MODEL_ID,
                    new SettingsConfiguration.Builder(SUPPORTED_TASK_TYPES).setDescription(
                        "Refer to the AI21 models documentation for the list of available inference models."
                    )
                        .setLabel("Model")
                        .setRequired(true)
                        .setSensitive(false)
                        .setUpdatable(false)
                        .setType(SettingsConfigurationFieldType.STRING)
                        .build()
                );

This comment applies to many other service settings fields, in particular ones for similarity, dimensions and embedding type for dense embedding service settings. I think we need to consider each service setting field carefully when deciding whether to allow it to be updated. The InferenceServiceConfiguration for a given service may be incomplete or incorrect, so I'm not sure it's safe to just go by what those say.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch on the updatable flag. I completely missed that. You’re right that it needs to be set appropriately for any setting we intend to allow updates on.
Historically it was set to false across the board because updateServiceSettings effectively didn’t support updates for most services (it was returning this in the majority of cases). This PR changes that behavior and makes updates possible, which is why these flags now matter. InferenceServiceConfigurations are often incomplete and incorrect and I, as an author of Ai21 chat integration didn't mean that model must be immutable.

I don't think we want to allow modelId to be updated.
doing so will cause the behaviour of the endpoint to change

I respectfully disagree here. Changing the modelId will indeed change the behavior of the endpoint. That’s inherently true for any configuration change that points to a different underlying model. Conceptually, updating modelId would mean swapping the provider endpoint model within the same elastic endpoint, which seems like a reasonable and potentially useful operation for customers.
As long as the updated configuration results in a valid and functional underlying endpoint, I don’t think we should artificially restrict this capability on our side. The behavior change is explicit and intentional from the user’s perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The reason we don't want to allow all fields to be updatable is that users can easily break their system. For example if a user ingests some documents with model_id_a and then changes it to model_id_b and ingests more documents, the embeddings could be incompatible. For chat completion and other task types it's not quite as bad but I still think we should consider some fields as immutable. If the user wants to use a different one, then they can create a new endpoint to do that.

Generally most things within service_settings probably shouldn't be updatable. Like Donal mentioned, we shouldn't allow updates for these fields in particular but there are probably more:

similarity
dimensions
embedding type
model id

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Understood. Will make the changes making those fields immutable post-creation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's the PR where model ID is immutable:
#142597

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug external-contributor Pull request authored by a developer outside the Elasticsearch team :SearchOrg/Inference Label for the Search Inference team Team:Search - Inference v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants