From e4531ebdc1770fcd4dbd17b58e61e9f37f9fcc8e Mon Sep 17 00:00:00 2001 From: Mauratay Date: Tue, 24 Feb 2026 12:43:52 -0600 Subject: [PATCH] SDK rejects valid numeric RAG Corpus IDs due to _VALID_RESOURCE_NAME_REGEX in _gapic_utils.py the SDK validates {rag_corpus} names against the following regex: _VALID_RESOURCE_NAME_REGEX = "[a-z][a-zA-Z0-9._-]{0,127}" Because this regex strictly requires the first character to be a lowercase letter [a-z], it fails for any numeric IDs generated by Google Cloud, causing functions like get_corpus_name to throw a confusing ValueError instructing the user to provide the correct format. Steps to reproduce: ~~~ import vertexai from vertexai.rag.utils import _gapic_utils # 1. Initialize Vertex AI vertexai.init(project="PROJECT_NAME", location="us-central1") # 2. Attempt to use a numeric rag_corpus ID try: formatted_name = _gapic_utils.get_corpus_name("123456789") print(f"Success: {formatted_name}") except ValueError as e: print(e) # Output: name must be of the format `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}` or `{rag_corpus}` ~~~ # BEFORE _VALID_RESOURCE_NAME_REGEX = "[a-z][a-zA-Z0-9._-]{0,127}" # AFTER _VALID_RESOURCE_NAME_REGEX = "[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}" --- vertexai/rag/utils/_gapic_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vertexai/rag/utils/_gapic_utils.py b/vertexai/rag/utils/_gapic_utils.py index 3ee39a7a0f..0104df41f8 100644 --- a/vertexai/rag/utils/_gapic_utils.py +++ b/vertexai/rag/utils/_gapic_utils.py @@ -67,7 +67,7 @@ ) -_VALID_RESOURCE_NAME_REGEX = "[a-z][a-zA-Z0-9._-]{0,127}" +_VALID_RESOURCE_NAME_REGEX = "[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}" _VALID_DOCUMENT_AI_PROCESSOR_NAME_REGEX = ( r"projects/[^/]+/locations/[^/]+/processors/[^/]+(?:/processorVersions/[^/]+)?" )