Skip to content

Commit 1292853

Browse files
authored
Allow colon inside source tags (#351)
## Problem Some partners have requested that colon, `:`, be added to the set of allowed characters inside source tags. ## Solution Add colon to the set of allowed characters. ## Type of Change - [x] New feature (non-breaking change which adds functionality) ## Test Plan Unit tests updated to reflect new allowed character.
1 parent 58d27ae commit 1292853

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pinecone/utils/user_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
def _build_source_tag_field(source_tag):
88
# normalize source tag
99
# 1. Lowercase
10-
# 2. Limit charset to [a-z0-9_ ]
10+
# 2. Limit charset to [a-z0-9_ :]
1111
# 3. Trim left/right whitespace
1212
# 4. Condense multiple spaces to one, and replace with underscore
1313
tag = source_tag.lower()
14-
tag = re.sub(r'[^a-z0-9_ ]', '', tag)
14+
tag = re.sub(r'[^a-z0-9_ :]', '', tag)
1515
tag = tag.strip()
1616
tag = "_".join(tag.split())
1717
return f"{SOURCE_TAG}={tag}"

tests/unit/utils/test_user_agent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def test_source_tag_is_normalized(self):
3333
useragent = get_user_agent(config)
3434
assert re.search(r"source_tag=my_source_tag_123", useragent) is not None
3535

36+
config = ConfigBuilder.build(api_key="my-api-key", host="https://my-controller-host", source_tag="colon:allowed")
37+
useragent = get_user_agent(config)
38+
assert re.search(r"source_tag=colon:allowed", useragent) is not None
39+
3640
def test_user_agent_grpc(self):
3741
config = ConfigBuilder.build(api_key="my-api-key", host="https://my-controller-host")
3842
useragent = get_user_agent_grpc(config)

0 commit comments

Comments
 (0)