Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public final class Messages {
public static final String INCONSISTENT_ID =
"Inconsistent {0}; ''{1}'' specified in the body differs from ''{2}'' specified as a URL argument";
public static final String INVALID_ID = "Invalid {0}; ''{1}'' can contain lowercase alphanumeric (a-z and 0-9), hyphens or "
+ "underscores; must start and end with alphanumeric";
+ "underscores; must start with alphanumeric or '.' and end with alphanumeric";
public static final String INVALID_MODEL_PACKAGE_ID = "Invalid {0}; ''{1}'' is not a valid model package id";
public static final String ID_TOO_LONG = "Invalid {0}; ''{1}'' cannot contain more than {2} characters.";
public static final String INVALID_GROUP = "Invalid group id ''{0}''; must be non-empty string and may contain lowercase alphanumeric"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ public final class MlStrings {
/**
* Valid user id pattern.
* Matches a string that contains lower case characters, digits, hyphens, underscores or dots.
* The string may start and end only in lower case characters or digits.
* The string may start and end only in lower case characters, digits or '.'.
* Note that '.' is allowed but not documented.
*/
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_\\-.]*[a-z0-9])$");

public static final int ID_LENGTH_LIMIT = 64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ public void testValidate() {
ActionRequestValidationException validationException = request.validate();
assertNull(validationException);

// valid model ID with . at start
var modelWithDotAtStart = new PutInferenceModelAction.Request(
TASK_TYPE,
"." +MODEL_ID + "_-0",
BYTES,
X_CONTENT_TYPE,
InferenceAction.Request.DEFAULT_TIMEOUT
);
assertNull(modelWithDotAtStart.validate());


// invalid model IDs

var invalidRequest = new PutInferenceModelAction.Request(
Expand Down