Skip to content

Conversation

1grzyb1
Copy link

@1grzyb1 1grzyb1 commented Oct 19, 2025

Aligned regex to allow. characters at the beginning and end of the model_id as mentioned in the issue.
Also added a test to cover such a case and an error message to match the current state

Fix #108426

@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v9.3.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Oct 19, 2025
@prwhelan prwhelan added :ml Machine learning Team:ML Meta label for the ML team >enhancement and removed needs:triage Requires assignment of a team area label labels Oct 20, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

Copy link
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.

The issue #108426 describes a problem with creating an inference endpoint with . characters at the start of the inference ID. This PR is making changes to allowed characters in a trained model alias, which is unrelated.

The regex that is used to check inference IDs is MlStrings.VALID_ID_CHAR_PATTERN, and it's tested in MlStringsTests and PutInferenceModelActionTests

@1grzyb1
Copy link
Author

1grzyb1 commented Oct 20, 2025

@DonalEvans I fixed it according to your comments. Can you take a look?

Copy link
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.

Please also update the tests in MlStringsTests to cover the new behaviour.

*/
private static final Pattern VALID_ID_CHAR_PATTERN = Pattern.compile("[a-z0-9](?:[a-z0-9_\\-\\.]*[a-z0-9])?");
private static final Pattern VALID_ID_CHAR_PATTERN =
Pattern.compile("^[a-z0-9.](?:[a-z0-9_\\-.]*[a-z0-9.])?$");
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that we want to allow IDs to end with ., the issue motivating this change only mentions allowing IDs to start with .

Copy link
Author

@1grzyb1 1grzyb1 Oct 20, 2025

Choose a reason for hiding this comment

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

Ok changed to allow only to start with .

Copy link
Contributor

@jonathan-buttner jonathan-buttner left a comment

Choose a reason for hiding this comment

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

Thanks for putting up the PR!

I'm not sure we want to allow inference endpoints that start with .. With the coming of dynamic inference endpoints from EIS we'll need a way to avoid users accidentally naming something the same thing that EIS will. Currently the only way to guarantee that is to prevent users from using inference endpoints that start with a ..

I'll chat with the team about this and let you know what we decide.

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 :ml Machine learning Team:ML Meta label for the ML team v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ML] Cannot create inference endpoint with id .elser_model_2 due to validation error

5 participants