Skip to content

fix(attribute-values): Handle boolean attributes#8000

Open
wmak wants to merge 2 commits into
masterfrom
wmak/fix/handle-boolean-attribute-values
Open

fix(attribute-values): Handle boolean attributes#8000
wmak wants to merge 2 commits into
masterfrom
wmak/fix/handle-boolean-attribute-values

Conversation

@wmak
Copy link
Copy Markdown
Member

@wmak wmak commented Jun 4, 2026

  • The endpoint allows attribute values but currently breaks because it makes some assumptions where the value would be a string. This fixes those cases so that we can use this endpoint for booleans

- The endpoint allows attribute values but currently breaks because it
  makes some assumptions where the value would be a string. This fixes
  those cases so that we can use this endpoint for booleans
@wmak wmak requested review from a team as code owners June 4, 2026 19:20
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5928272. Configure here.

Comment thread snuba/web/rpc/v1/trace_item_attribute_values.py Outdated
Comment thread snuba/web/rpc/v1/trace_item_attribute_values.py
Comment on lines +64 to +66
[
f.has(column("attributes_bool"), name)
for name in _map_key_names_for_existence_check(request.key)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The code uses f.has() on the attributes_bool map, which translates to an incorrect ClickHouse function (has() instead of mapContains()), causing query failures.
Severity: HIGH

Suggested Fix

Replace the call to f.has(column("attributes_bool"), name) with f.mapContains(column("attributes_bool"), name). This will generate the correct mapContains() function in the ClickHouse query, which is designed to work with Map data types.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: snuba/web/rpc/v1/trace_item_attribute_values.py#L64-L66

Potential issue: The code uses `f.has(column("attributes_bool"), name)` to query a map
column. However, the query processor `HashMapHasFunctionTransformer` is not configured
to handle the `attributes_bool` column. As a result, the function call is passed
directly to ClickHouse as `has(attributes_bool, 'attribute_name')`. The ClickHouse
`has()` function is designed for arrays, not maps. The correct function for checking key
existence in a map is `mapContains()`. This will cause a runtime type error in
ClickHouse whenever a query for a boolean attribute is executed, breaking the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant