Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
d3a1abc
fix: update test assertion and EntityCsv string to match updated enti…
jaya6400 May 4, 2026
3dfaab2
fix: correct EntityCsv contains() string escaping for name validation…
jaya6400 May 4, 2026
d5c9c07
fix: convert CRLF to LF in ValidatorUtilTest.java
jaya6400 May 4, 2026
89d0cd3
fix(validation): reject reserved FQN characters in entity and column …
jaya6400 Apr 19, 2026
fcfc2a6
fix(validation): also block control characters in entity name pattern
jaya6400 Apr 19, 2026
ea38aad
fix(validation): extend entity name validation to cover additional sc…
jaya6400 Apr 22, 2026
d89fdff
fix(validation): add < and | to columnName pattern in table.json
jaya6400 Apr 22, 2026
dabd075
fix(lint): disable no-control-regex for intentional control char rang…
jaya6400 Apr 22, 2026
4e03649
fix(tests): add integration tests for entity name validation with res…
jaya6400 Apr 25, 2026
eebb577
fix(validation): add minLength:1 to pipeline task name and apply spot…
jaya6400 Apr 25, 2026
36d5ae3
fix: fix line endings and formatting in PipelineValidation spec
jaya6400 Apr 29, 2026
08cd15d
fix: add pipe character test case and clarify regex comment
jaya6400 May 4, 2026
88a756e
Merge branch 'main' into fix/entity-name-validation-v2
aniketkatkar97 May 5, 2026
7ca1365
style: apply spotless formatting
jaya6400 May 7, 2026
cfe03d4
fix(search): index classification display name for tags
jaya6400 May 7, 2026
1f1d3c0
fix(validation): use pydantic-compatible entity name pattern:
jaya6400 May 8, 2026
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 @@ -28,8 +28,11 @@
import jakarta.validation.Validator;
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
Expand Down Expand Up @@ -155,6 +158,9 @@ public void launcherSessionOpened(LauncherSession session) {
rdfEnabled = Boolean.parseBoolean(System.getProperty("enableRdf", "false"));

LOG.info("=== TestSuiteBootstrap: Starting test infrastructure ===");
System.setProperty("user.timezone", "UTC");
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
LOG.info("Test JVM timezone set to {}", TimeZone.getDefault().getID());
LOG.info("Database type: {}", databaseType);
LOG.info("Search type: {}", searchType);
LOG.info("RDF enabled: {}", rdfEnabled);
Expand Down Expand Up @@ -427,8 +433,10 @@ private void startApplication() throws Exception {
config.setDataSourceFactory(dataSourceFactory);

String projectRoot = System.getProperty("user.dir");
if (projectRoot.endsWith("openmetadata-integration-tests")) {
projectRoot = projectRoot.substring(0, projectRoot.lastIndexOf("/"));
Path projectRootPath = Paths.get(projectRoot);
if (projectRootPath.endsWith("openmetadata-integration-tests")
&& projectRootPath.getParent() != null) {
projectRoot = projectRootPath.getParent().toString();
}
String flyWayMigrationScriptsLocation =
projectRoot + "/bootstrap/sql/migrations/flyway/" + DATABASE_CONTAINER.getDriverClassName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,21 @@ void post_pipelineWithTasks_200_OK(TestNamespace ns) {
assertEquals(2, pipeline.getTasks().size());
}

@Test
void post_pipelineWithInvalidTaskName_4xx(TestNamespace ns) {
PipelineService service = PipelineServiceTestFactory.createAirflow(ns);

CreatePipeline request = new CreatePipeline();
request.setName(ns.prefix("pipeline_invalid_task"));
request.setService(service.getFullyQualifiedName());
request.setTasks(List.of(new Task().withName("task<invalid")));

assertThrows(
Exception.class,
() -> createEntity(request),
"Creating pipeline with invalid task name should fail");
}

@Test
void post_pipelineWithSourceUrl_200_OK(TestNamespace ns) {
OpenMetadataClient client = SdkClients.adminClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,25 @@ void post_searchIndexWithFields_200_OK(TestNamespace ns) {
assertEquals(2, searchIndex.getFields().size());
}

@Test
void post_searchIndexWithInvalidFieldName_4xx(TestNamespace ns) {
SearchService service = SearchServiceTestFactory.createElasticSearch(ns);

CreateSearchIndex request = new CreateSearchIndex();
request.setName(ns.prefix("searchindex_invalid_field"));
request.setService(service.getFullyQualifiedName());
request.setFields(
List.of(
new SearchIndexField()
.withName("title<invalid")
.withDataType(SearchIndexDataType.TEXT)));

assertThrows(
Exception.class,
() -> createEntity(request),
"Creating search index with invalid field name should fail");
}

@Test
void put_searchIndexFields_200_OK(TestNamespace ns) {
OpenMetadataClient client = SdkClients.adminClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,38 @@ protected Table createEntity(CreateTable createRequest) {
return SdkClients.adminClient().tables().create(createRequest);
}

@Test
void post_tableWithInvalidConstraintOrPartitionColumnName_4xx(TestNamespace ns) {
CreateTable invalidConstraintRequest = createMinimalRequest(ns);
invalidConstraintRequest.setName(ns.prefix("table_invalid_constraint_column"));
invalidConstraintRequest.setTableConstraints(
List.of(
new TableConstraint()
.withConstraintType(TableConstraint.ConstraintType.UNIQUE)
.withColumns(List.of("name<invalid"))));

assertThrows(
Exception.class,
() -> createEntity(invalidConstraintRequest),
"Creating table with invalid constraint column name should fail");

CreateTable invalidPartitionRequest = createMinimalRequest(ns);
invalidPartitionRequest.setName(ns.prefix("table_invalid_partition_column"));
invalidPartitionRequest.setTablePartition(
new TablePartition()
.withColumns(
List.of(
new PartitionColumnDetails()
.withColumnName("name|invalid")
.withIntervalType(PartitionIntervalTypes.COLUMN_VALUE)
.withInterval("daily"))));

assertThrows(
Exception.class,
() -> createEntity(invalidPartitionRequest),
"Creating table with invalid partition column name should fail");
}

@Override
protected Table getEntity(String id) {
return SdkClients.adminClient().tables().get(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,28 @@ void post_topicWithMessageSchema_200_OK(TestNamespace ns) {
assertNotNull(topic.getMessageSchema().getSchemaFields());
}

@Test
void post_topicWithInvalidSchemaFieldName_4xx(TestNamespace ns) {
MessagingService service = MessagingServiceTestFactory.createKafka(ns);

MessageSchema schema =
new MessageSchema()
.withSchemaType(SchemaType.JSON)
.withSchemaFields(
List.of(new Field().withName("field|invalid").withDataType(FieldDataType.STRING)));

CreateTopic request = new CreateTopic();
request.setName(ns.prefix("topic_invalid_schema_field"));
request.setService(service.getFullyQualifiedName());
request.setPartitions(1);
request.setMessageSchema(schema);

assertThrows(
Exception.class,
() -> createEntity(request),
"Creating topic with invalid schema field name should fail");
}

@Test
void post_topicWithCleanupPolicies_200_OK(TestNamespace ns) {
OpenMetadataClient client = SdkClients.adminClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ protected void createUserEntity(CSVPrinter resultsPrinter, CSVRecord csvRecord,

if (violations == null || violations.isEmpty()) {
userNameEmailViolation = ValidatorUtil.validateUserNameWithEmailPrefix(csvRecord);
} else if (!violations.contains("name must match \"^((?!::).)*$\"")
} else if (!violations.contains("name must match \"^((?!::)[^><\"|\\x00-\\x1f])*$\"")
&& !violations.contains("email must be a well-formed email address")) {
userNameEmailViolation = ValidatorUtil.validateUserNameWithEmailPrefix(csvRecord);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void testValidator() {

// Invalid name
glossary.withName("invalid::Name").withDescription("description");
assertEquals("[name must match \"^((?!::).)*$\"]", ValidatorUtil.validate(glossary));
assertEquals("[name must match \"^((?!::)[^><\"|\\x00-\\x1f])*$\"]", ValidatorUtil.validate(glossary));

// No error
glossary.withName("validName").withId(UUID.randomUUID()).withDescription("description");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@
"properties": {
"name": {
"description": "Name that identifies this task instance uniquely.",
"type": "string"
"type": "string",
"minLength": 1,
"pattern": "^((?!::)[^><\"|\\x00-\\x1f])*$"
},
"displayName": {
"description": "Display Name that identifies this Task. It could be title or label from the pipeline services.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"type": "string",
"minLength": 1,
"maxLength": 256,
"pattern": "^((?!::).)*$"
"pattern": "^((?!::)[^><\"|\\x00-\\x1f])*$"
},
"searchIndexField": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@
"description": "List of column names corresponding to the constraint.",
"type": "array",
"items": {
"type": "string"
"type": "string",
"pattern": "^((?!::)[^><\"|\\x00-\\x1f])*$"
}
},
"referredColumns": {
Expand All @@ -235,7 +236,7 @@
"description": "Local name (not fully qualified name) of the column. ColumnName is `-` when the column is not named in struct dataType. For example, BigQuery supports struct with unnamed fields.",
"type": "string",
"minLength": 1,
"pattern": "^((?!::).)*$"
"pattern": "^((?!::)[^><\"|\\x00-\\x1f])*$"
},
"partitionIntervalTypes": {
"javaType": "org.openmetadata.schema.type.PartitionIntervalTypes",
Expand Down Expand Up @@ -273,7 +274,8 @@
"properties": {
"columnName": {
"description": "List of column names corresponding to the partition.",
"type": "string"
"type": "string",
"pattern": "^((?!::)[^><\"|\\x00-\\x1f])*$"
},
"intervalType": {
"$ref": "#/definitions/partitionIntervalTypes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@
"type": "string",
"minLength": 1,
"maxLength": 256,
"pattern": "^((?!::).)*$"
"pattern": "^((?!::)[^><\"|\\x00-\\x1f])*$"
},
"testCaseEntityName": {
"description": "Name that identifies a test definition and test case.",
"type": "string",
"minLength": 1,
"pattern": "^((?!::).)*$"
"pattern": "^((?!::)[^><\"|\\x00-\\x1f])*$"
},
"fullyQualifiedEntityName": {
"description": "A unique name that identifies an entity. Example for table 'DatabaseService.Database.Schema.Table'.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"description": "Local name (not fully qualified name) of the field. ",
"type": "string",
"minLength": 1,
"maxLength": 128
"maxLength": 128,
"pattern": "^((?!::)[^><\"|\\x00-\\x1f])*$"
},
"field": {
"type": "object",
Expand Down Expand Up @@ -139,4 +140,4 @@
"default": []
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright 2026 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { expect, test, type APIRequestContext } from '@playwright/test';
import { getDefaultAdminAPIContext, uuid } from '../../utils/common';

test.use({ storageState: 'playwright/.auth/admin.json' });

test.describe('Pipeline entity name validation', () => {
let apiContext: APIRequestContext;
let afterAction: () => Promise<void>;
let serviceFqn = '';

test.beforeAll(async ({ browser }) => {
const response = await getDefaultAdminAPIContext(browser);
apiContext = response.apiContext;
afterAction = response.afterAction;

const serviceName = `pw-pipeline-validation-service-${uuid()}`;
const serviceResponse = await apiContext.post(
'/api/v1/services/pipelineServices',
{
data: {
name: serviceName,
serviceType: 'Dagster',
connection: {
config: {
type: 'Dagster',
host: 'admin',
token: 'admin',
timeout: '1000',
supportsMetadataExtraction: true,
},
},
},
}
);

expect(serviceResponse.status()).toBe(201);
const serviceData = await serviceResponse.json();
serviceFqn = serviceData.fullyQualifiedName;
});

test.afterAll(async () => {
if (serviceFqn) {
await apiContext.delete(
`/api/v1/services/pipelineServices/name/${encodeURIComponent(
serviceFqn
)}?recursive=true&hardDelete=true`
);
}
await afterAction();
});

test('should reject pipeline creation when task name is empty', async () => {
const response = await apiContext.post('/api/v1/pipelines', {
data: {
name: `pw-pipeline-empty-task-${uuid()}`,
service: serviceFqn,
tasks: [{ name: '' }],
},
});

expect(response.status()).toBe(400);
});

test('should reject pipeline creation when task name contains reserved FQN characters', async () => {
const response = await apiContext.post('/api/v1/pipelines', {
data: {
name: `pw-pipeline-invalid-task-${uuid()}`,
service: serviceFqn,
tasks: [{ name: 'task<invalid' }],
},
});

expect(response.status()).toBe(400);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ describe('Test Regex', () => {
it('EntityName regex should fail for the invalid entity name', () => {
// conatines :: in the name should fail
expect(ENTITY_NAME_REGEX.test('Hello::World')).toEqual(false);
expect(ENTITY_NAME_REGEX.test('name>bad')).toEqual(false);
expect(ENTITY_NAME_REGEX.test('name<bad')).toEqual(false);
expect(ENTITY_NAME_REGEX.test('name"bad')).toEqual(false);
expect(ENTITY_NAME_REGEX.test('name\nbad')).toEqual(false);
expect(ENTITY_NAME_REGEX.test('name\rbad')).toEqual(false);
expect(ENTITY_NAME_REGEX.test('name\x00bad')).toEqual(false);
Comment thread
gitar-bot[bot] marked this conversation as resolved.
});

describe('TAG_NAME_REGEX', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ export const UrlEntityCharRegEx = /[#.%;?/\\]/g;
export const EMAIL_REG_EX = /^\S+@\S+\.\S+$/;

/**
* strings that contain a combination of letters, alphanumeric characters, hyphens,
* spaces, periods, single quotes, ampersands, and parentheses, with support for Unicode characters.
* Validates entity names. Blocks reserved FQN separator characters (::, >, <, ", |)
* and ASCII control characters. Supports Unicode characters.
*/
export const ENTITY_NAME_REGEX = /^((?!::).)*$/;
// eslint-disable-next-line no-control-regex
export const ENTITY_NAME_REGEX = /^((?!::)[^><"|\u0000-\u001f])*$/;

/**
* Matches any string that does NOT contain the following:
Expand Down
Loading