microsoft/semantic-kernel · error · VectorStoreOperationException

Invalid identifier with quotes: {name}

Error message

Invalid identifier with quotes: {name}

What it means

Thrown by OracleCollection._validate_identifiers when an identifier contains a double-quote character. The connector builds quoted identifiers ("name") in its SQL, so an embedded double quote would break the quoting boundary and enable SQL injection; such names are rejected outright.

Source

Thrown at python/semantic_kernel/connectors/oracle.py:490

            )

        return None

    @override
    def _serialize_dicts_to_store_models(self, records: Sequence[dict[str, Any]], **kwargs: Any) -> Sequence[Any]:
        """Serialize a list of dicts of the data to the store model. Pass the records through without modification."""
        return records

    def _validate_identifiers(self, name: str) -> None:
        """Validate Oracle identifier to disallow embedded double quotes.

        Since quoted identifiers are not allowed, any double quote is invalid.
        """
        if not name:
            raise VectorStoreOperationException("Identifier cannot be empty")

        if '"' in name:
            raise VectorStoreOperationException(f"Invalid identifier with quotes: {name}")

    def _build_check_table_exists_query(self) -> tuple[str, dict[str, str]]:
        """Build SQL + bind variables for checking table existence.

        - If schema is provided, query ALL_TABLES.
        - If no schema, query USER_TABLES.
        """
        if self.db_schema:
            sql = """
                SELECT 1
                FROM   all_tables
                WHERE  owner = :owner
                AND    table_name = :tbl
            """
            bind_vars = {
                "owner": self.db_schema,
                "tbl": self.collection_name,
            }

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Strip or reject double quotes from collection, schema, and field names before construction
  2. Use plain alphanumeric identifiers with underscores (standard Oracle naming)
  3. Never pass untrusted user input directly as an identifier - map it to a safe name first
  4. Validate identifiers with a regex like ^[A-Za-z_][A-Za-z0-9_]*$ before passing them in

Example fix

# before
table = request.args['table']  # e.g. 'foo" -- drop'
OracleCollection(record_type=MyModel, collection_name=table)  # raises 1514

# after - sanitize
import re
safe = re.sub(r'[^A-Za-z0-9_]', '', request.args['table']) or 'default'
OracleCollection(record_type=MyModel, collection_name=safe)
Defensive patterns

Strategy: validation

Validate before calling

import re

def sanitize_identifier(name: str) -> str:
    cleaned = re.sub(r'[^A-Za-z0-9_]', '', name or '')
    if not cleaned:
        raise ValueError(f'Invalid identifier: {name!r}')
    return cleaned

# use before constructing the collection or fields
collection_name = sanitize_identifier(user_input)

Type guard

import re

def is_safe_identifier(name: str) -> bool:
    return isinstance(name, str) and '"' not in name and bool(re.match(r'^[A-Za-z_][A-Za-z0-9_]*$', name))

Try / catch

from semantic_kernel.exceptions import VectorStoreOperationException

try:
    collection = OracleCollection(record_type=MyModel, collection_name=name)
except VectorStoreOperationException as e:
    if 'Invalid identifier with quotes' in str(e):
        # strip quotes / sanitize the name and retry
        ...

Prevention

When it happens

Trigger: collection_name, db_schema, or a field name/storage_name containing a '"' character; typically from unsanitized user-controlled input passed as a table or column name.

Common situations: User-supplied table/column names not sanitized; copy-paste artifact including a quote; attempting to use Oracle quoted-identifier semantics through the name string.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/f05c3027f2cfaf69. Report an issue: GitHub.