OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

Backend: Validate if the entity names are valid in terms of Name, Fqn

Open ayush-shah opened this issue 1 year ago • 8 comments

On Creating an entity with special characters like quotes, backend should not allow creation of it since they are reserved keywords, we will provide support if someone faces this issue by adding in the custom basemodel / custom pydantic code

ayush-shah avatar Sep 05 '25 08:09 ayush-shah

Payload to create - Json column with quotes in between, similar issues happen for dashboard data models

{
    "name": "table_entity",
    "tableType": "Regular",
    "columns": [
        {
            "name": "id",
            "displayName": "",
            "dataType": "BOOLEAN",
            "dataLength": 36,
            "dataTypeDisplay": "varchar(36)",
            "description": "",
            "fullyQualifiedName": "sample_data.ecommerce_db.shopify.table_entity.id",
            "tags": [],
            "ordinalPosition": 1,
            "children": [],
            "customMetrics": []
        },
        {
            "name": "jso\"n\"",
            "displayName": "",
            "dataType": "JSON",
            "dataLength": 1,
            "dataTypeDisplay": "json",
            "description": "",
            "fullyQualifiedName": "sample_data.ecommerce_db.shopify.table_entity.json",
            "tags": [],
            "constraint": "NOT_NULL",
            "ordinalPosition": 2,
            "children": [],
            "customMetrics": []
        },
        {
            "name": "updatedAt",
            "displayName": "",
            "dataType": "BIGINT",
            "dataLength": 1,
            "dataTypeDisplay": "bigint",
            "description": "",
            "fullyQualifiedName": "sample_data.ecommerce_db.shopify.table_entity.updatedAt",
            "tags": [],
            "constraint": "NULL",
            "ordinalPosition": 3,
            "children": [],
            "customMetrics": []
        },
        {
            "name": "updatedBy",
            "displayName": "",
            "dataType": "VARCHAR",
            "dataLength": 256,
            "dataTypeDisplay": "varchar(256)",
            "description": "",
            "fullyQualifiedName": "sample_data.ecommerce_db.shopify.table_entity.updatedBy",
            "tags": [],
            "constraint": "NULL",
            "ordinalPosition": 4,
            "children": [],
            "customMetrics": []
        },
        {
            "name": "deleted",
            "displayName": "",
            "dataType": "TINYINT",
            "dataLength": 1,
            "dataTypeDisplay": "tinyint",
            "description": "",
            "fullyQualifiedName": "sample_data.ecommerce_db.shopify.table_entity.deleted",
            "tags": [],
            "constraint": "NULL",
            "ordinalPosition": 5,
            "children": [],
            "customMetrics": []
        },
        {
            "name": "fqnHash",
            "displayName": "",
            "dataType": "VARCHAR",
            "dataLength": 768,
            "dataTypeDisplay": "varchar(768)",
            "description": "",
            "fullyQualifiedName": "sample_data.ecommerce_db.shopify.table_entity.fqnHash",
            "tags": [],
            "constraint": "UNIQUE",
            "ordinalPosition": 6,
            "children": [],
            "customMetrics": []
        },
        {
            "name": "name",
            "displayName": "",
            "dataType": "VARCHAR",
            "dataLength": 256,
            "dataTypeDisplay": "varchar(256)",
            "description": "",
            "fullyQualifiedName": "sample_data.ecommerce_db.shopify.table_entity.name",
            "tags": [],
            "constraint": "NOT_NULL",
            "ordinalPosition": 7,
            "children": [],
            "customMetrics": []
        }
    ],
    "tableConstraints": [],
    "owners": [],
    "databaseSchema": "sample_data.ecommerce_db.shopify"
    
    
}

ayush-shah avatar Sep 05 '25 08:09 ayush-shah

@harshach Hi, I've a background in backend dev and I'd like to fix this by adding name/FQN validation in the base model to reject special characters like quotes and newlines. Requesting assignment. I'll raise a PR for the same after checking the codebase.

jaya6400 avatar Apr 18 '26 19:04 jaya6400

@jaya6400 assigned it to you

harshach avatar Apr 18 '26 19:04 harshach

I've raised a PR for this fix: #27521. It updates the regex patterns in basic.json and table.json to block reserved FQN characters (>, ") and control characters (\x00-\x1f) in entity and column names. Ready for maintainer's review.

jaya6400 avatar Apr 19 '26 09:04 jaya6400

Hi, I'd like to work on this issue. I have experience with Java and Spring Boot backend development. Can you assign it to me?

srinithreddy16 avatar May 26 '26 23:05 srinithreddy16

Sorry, I just noticed this issue is already being worked on. I will pick up another issue. Thanks!

srinithreddy16 avatar May 26 '26 23:05 srinithreddy16

Hi, I’m interested in working on this as my first contribution to OpenMetadata. I’m a CS student with backend experience in Java, Spring Boot, PostgreSQL, validation logic, and API workflows. Could I be assigned to this issue?

Moustafa-Ameen avatar Jun 29 '26 16:06 Moustafa-Ameen

@Moustafa-Ameen hi, I am already working on this PR, waiting for maintainer re-review on my PR comment.

  • https://github.com/open-metadata/OpenMetadata/pull/27886#issuecomment-4754296398

jaya6400 avatar Jun 29 '26 16:06 jaya6400