Skip to content

Do not skip sequence attribute on decode error #2097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2096](https://github.com/open-telemetry/opentelemetry-python/pull/2096))
- Fix propagation bug caused by counting skipped entries
([#2071](https://github.com/open-telemetry/opentelemetry-python/pull/2071))
- Do not skip sequence attribute on decode error
([#2097](https://github.com/open-telemetry/opentelemetry-python/pull/2097))

## [1.5.0-0.24b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.5.0-0.24b0) - 2021-08-26

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ def _clean_attribute(
cleaned_seq = []

for element in value:
# None is considered valid in any sequence
if element is None:
cleaned_seq.append(element)

element = _clean_attribute_value(element, max_len)
# reject invalid elements
if element is None:
cleaned_seq.append(element)
continue

element_type = type(element)
Expand Down
19 changes: 19 additions & 0 deletions opentelemetry-api/tests/attributes/test_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ def test_clean_attribute(self):
self.assertInvalid("value", "")
self.assertInvalid("value", None)

def test_sequence_attr_decode(self):
seq = [
None,
b"Content-Disposition",
b"Content-Type",
b"\x81",
b"Keep-Alive",
]
expected = [
None,
"Content-Disposition",
"Content-Type",
None,
"Keep-Alive",
]
self.assertEqual(
_clean_attribute("headers", seq, None), tuple(expected)
)


class TestBoundedAttributes(unittest.TestCase):
base = collections.OrderedDict(
Expand Down