Skip to content

Commit f025b52

Browse files
committed
fix baggage escape
1 parent 05487b3 commit f025b52

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

CHANGLOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.1.19] - 2025-11-10
2+
### Fixed
3+
- fix baggage escape problem
4+
15
## [0.1.18] - 2025-10-10
26
### Added
37
- fix prompt syntax error, use Union instead of |

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The CozeLoop SDK is a Python client for interacting with [CozeLoop platform](htt
77
Key features:
88
- Report trace
99
- Get and format prompt
10+
- Execute Prompt as a Service (PTaaS)
1011

1112
## Requirements
1213
- Python 3.8 or higher

README.zh_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CozeLoop SDK 是一个用于与 [CozeLoop 平台](https://loop.coze.cn) 进行
77
主要功能:
88
- Trace上报
99
- Prompt拉取
10+
- 执行Prompt as a Service (PTaaS)
1011

1112
## 要求
1213
- Python 3.8 或更高版本

cozeloop/internal/trace/span.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,18 +458,15 @@ def set_multi_modality_map(self, key: str):
458458
def set_baggage(self, baggage_item: Dict[str, str]):
459459
if not baggage_item:
460460
return
461-
self.set_baggage_escape(baggage_item, True)
461+
self.set_baggage_escape(baggage_item)
462462

463-
def set_baggage_escape(self, baggage_item: Dict[str, str], escape: bool):
463+
def set_baggage_escape(self, baggage_item: Dict[str, str]):
464464
if not baggage_item:
465465
return
466466
try:
467467
for key, value in baggage_item.items():
468468
if self.is_valid_baggage_item(key, value):
469469
self.set_tags({key: value})
470-
if escape:
471-
key = urllib.parse.quote(key)
472-
value = urllib.parse.quote(value)
473470
self.set_baggage_item(key, value)
474471
else:
475472
logger.error(f"[trace] invalid baggageItem:{key}:{value}")
@@ -565,7 +562,7 @@ def to_header(self) -> Dict[str, str]:
565562
def to_header_baggage(self) -> str:
566563
if not self.baggage:
567564
return ""
568-
return ",".join(f"{k}={v}" for k, v in self.baggage().items() if k and v)
565+
return ",".join(f"{urllib.parse.quote(k)}={urllib.parse.quote(v)}" for k, v in self.baggage().items() if k and v)
569566

570567
def to_header_parent(self) -> str:
571568
return f"{GLOBAL_TRACE_VERSION:02x}-{self.trace_id}-{self.span_id}-{self.flags:02x}"

cozeloop/internal/trace/trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _start_span(self,
145145
tag_truncate_conf=self.tag_truncate_conf,
146146
)
147147

148-
span.set_baggage_escape(baggage, False)
148+
span.set_baggage_escape(baggage)
149149
return span
150150

151151
def flush(self):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cozeloop"
3-
version = "0.1.18"
3+
version = "0.1.19"
44
description = "coze loop sdk"
55
authors = ["JiangQi715 <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)