Skip to content

getMapKeys returns no keys when the mergeTreeTextIndex query fails (e.g. ACCESS_DENIED under row policies) instead of falling through #3265

Closed

Description

@squaredg

What happened?

Map key discovery returns an empty list when the mergeTreeTextIndex query fails, instead of falling through to the rollup and bounded-scan paths.

This breaks key discovery on tables with row policies. ClickHouse refuses mergeTreeTextIndex with ACCESS_DENIED whenever a row policy applies to the table (ClickHouse/ClickHouse#119032), and getMapKeys turns that error into []. The bounded mapKeys scan, which reads the table itself and respects row policies, never runs. Search bar autocomplete shows no keys for those Map columns.

Expected: if the text-index query fails, getMapKeys should log and try the next strategy, the same way it already does when the index query succeeds but returns no keys.

The short-circuit is in both catch blocks in getMapKeys:

The other text-index readers (getMapTextIndexKeyValues, getTextIndexKeyValues) already skip the failed strategy and continue, so this would make getMapKeys consistent with them.

The bug only shows when the user can read system.data_skipping_indices. Without that grant, HyperDX doesn't detect the text index and goes straight to the scan, which works.

The only workaround today is dropping the *_attr_key / *_attr_kv text indexes on the protected tables. That moves discovery to the scan path but makes key loading slower for everyone using those tables. There's no per-source setting to skip the text index for key discovery.

Related: #2880 hits the same short-circuit with a different error (BAD_ARGUMENTS on Distributed tables).

Steps to reproduce

  1. On ClickHouse 26.8.15 (any release with Text index: make mergeTreeTextIndex stricter when a row policy applies ClickHouse#119032), create otel_logs from the seed schema, which includes idx_log_attr_key on mapKeys(LogAttributes), and insert rows from two services with different LogAttributes keys.
  2. Create a user with GRANT SELECT ON default.* and GRANT SELECT ON system.data_skipping_indices, and a row policy on the table for that user: CREATE ROW POLICY api_only ON default.otel_logs USING ServiceName = 'api' TO rp_user.
  3. Add a HyperDX connection as that user and a log source on otel_logs.
  4. On the search page, type LogAttributes. in the search bar. No keys are suggested. The same source on a connection as the default user suggests all keys.

How are you running HyperDX?

Reported on HyperDX 2.39.1. Reproduced on a local dev stack at main (b52adf7) with ClickHouse 26.8.15.10.

Where does it show up?

UI: search bar autocomplete for Map attribute columns (verified). Other features that use getMapKeys are likely affected too.

Debug info

N/A

Logs

Browser console during the reproduction:

getMapKeys rollup query failed for key text index query ClickHouseQueryError: Cannot read from `mergeTreeTextIndex` because a row policy is applied on table default.otel_logs (<uuid>). The text index covers all rows of the table, so reading its tokens would violate the row policy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions