TraceState does not check illegal inputs

未關閉
#5,136 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

@Abhinav0905 已經在處理了。

開始於 2026年8月9日。

  • #5173 來自 @64johnlee —— 已關閉,未合併
  • #5599 來自 @sidsri14 —— 已關閉,未合併

評估

難度
3/5
預估耗時
1-2 天
新手友好度
65/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
python

研究方向

從 TraceState.add 開始,重現所提供的案例,將被接受的有效 tenant ID 與應被拒絕的輸入進行比較。追蹤現有的驗證及其測試,然後確保所列出的非法格式和長度會被拒絕,同時有效案例仍會被接受;執行相關的 TraceState 測試套件。

由索引模型根據 Issue 內容生成。

描述

bug
Describe your environment

OS: Windows
Python version: Python 3.13
SDK version: the latest
API version: the latest

TraceState.add() does not fully check whether the inputs are correct.

What happened?

TraceState.add() should reject the illegal inputs.

Steps to Reproduce

Here is my test case:

`from opentelemetry.trace import TraceState

Java constants mapped to Python

EMPTY = TraceState()
FIRST_VALUE = "first_value" # Adjust to match your test's actual constant
class MyTestCase(unittest.TestCase):

def test_valid_long_tenant_id(self):
    result = EMPTY.add("12345678901234567890@nr", FIRST_VALUE)
    assert result.get("12345678901234567890@nr") == FIRST_VALUE


def test_vendor_id_longer_than_13_characters(self):
    with self.assertRaises(Exception) as context:
        EMPTY.add("1@nrabcdefghijkl", FIRST_VALUE)
    self.assertTrue('This is broken' in context.exception)

def test_vendor_id_longer_than_13_characters_long_tenant_id(self):
    with self.assertRaises(Exception) as context:
        EMPTY.add("12345678901234567890@nrabcdefghijkl", FIRST_VALUE)
    self.assertTrue('This is broken' in context.exception)

def test_tenant_id_longer_than_240_characters(self):
    tenant_id = "a" * 241
    with self.assertRaises(Exception) as context:
        EMPTY.add(f"{tenant_id}@nr", FIRST_VALUE)
    self.assertTrue('This is broken' in context.exception)

def test_non_vendor_format_first_key_character(self):
    with self.assertRaises(Exception) as context:
        EMPTY.add("1acdfrgs", FIRST_VALUE)
    self.assertTrue('This is broken' in context.exception)`
Expected Result

Shall reject.

Actual Result

Added.

Additional context

No response

Would you like to implement a fix?

None

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

主要語言
Python
星號
2.7k
分支
1.1k
平均合併
3 天 12 小時
30 天內合併 PR
16

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

open-telemetry/opentelemetry-python 的其他 Issue

查看 open-telemetry/opentelemetry-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。