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 摘要。