Skip to content

Settings profile with a Map setting (http_response_headers) does not survive a serialization round trip #114591

Closed

Description

@pufit

Company or project name

ClickHouse

Describe the unexpected behaviour

An access entity with a Map-valued setting — e.g. a settings profile with http_response_headers — is serialized into a form that ClickHouse's own parser cannot read back. The stored entity becomes permanently unloadable.

How to reproduce

-- A string literal is the only accepted way to write a Map setting in a profile
-- (map literals {...}, array literals [...], and map(...) are all rejected here):
CREATE SETTINGS PROFILE test_profile SETTINGS http_response_headers = '{''Content-Type'':''application/json'', ''Access-Control-Allow-Origin'':''*''}' CONST;

SHOW CREATE SETTINGS PROFILE test_profile;
-- CREATE SETTINGS PROFILE `test_profile` SETTINGS http_response_headers = [('Content-Type', 'application/json'), ('Access-Control-Allow-Origin', '*')] CONST

-- Feeding the emitted statement back — which is exactly what DiskAccessStorage and
-- ReplicatedAccessStorage store and re-parse via deserializeAccessEntity:
CREATE SETTINGS PROFILE test_profile2 SETTINGS http_response_headers = [('Content-Type', 'application/json'), ('Access-Control-Allow-Origin', '*')] CONST;
-- Code: 62. DB::Exception: Syntax error: failed at position 72 ([):
-- Expected one of: literal, NULL, NULL, number, Bool, TRUE, FALSE, string literal, end of query

No value of the setting round-trips — even an empty map serializes as [] CONST, which is rejected the same way.

Root cause

The write path and the read path disagree:

  • Write: SettingsProfileElement (src/Access/SettingsProfileElement.cpp) casts the value to the setting's native type (Map), and the AST formats the Field as a literal, producing an array-of-tuples literal [('k', 'v'), ...].
  • Read: ParserSettingsProfileElement (src/Parsers/Access/ParserSettingsProfileElement.cpp) parses the value with a scalar-only literal parser. Unlike the query-level SETTINGS clause parser, it was never extended to accept collection literals (cf. Cannot use map() in SETTINGS #75065, where the query-level parser expects literal or map, ..., OpeningCurlyBrace).

So serializeAccessEntity → deserializeAccessEntity fails for any user/role/profile whose profile elements contain a collection-valued setting (http_response_headers, additional_table_filters, ...).

Generated by Nerve

Version info

Activity

  1. added
    potential bug
    on Aug 13, 2026
  2. pufit commented on Aug 13, 2026

    @pufit
    MemberAuthor

    @groeneai fix this

  3. groeneai commented on Aug 13, 2026

    @groeneai
    Collaborator

    Acknowledged - reproduced on master (26.8.1.1), and the persistence half is confirmed too: the stored access/<uuid>.sql holds ATTACH SETTINGS PROFILE pers SETTINGS http_response_headers = [('a', 'b')] CONST;, and the next startup fails the whole access-storage load with Code: 62 ... Could not parse .../access/<uuid>.sql, not just that one entity.

    Your root cause matches the source: parseValue in ParserSettingsProfileElement.cpp uses scalar-only ParserLiteral, while the query-level SETTINGS parser (ParserSetQuery.cpp) uses ParserAllCollectionsOfLiterals. additional_table_filters and the empty-map case reproduce identically, so I will fix the collection-valued class rather than the one setting. I will follow up here with the PR.

  4. groeneai commented on Aug 13, 2026

    @groeneai
    Collaborator

    Fix is up: #114620

    The write side was at fault, so the change is there: when a profile element's value, MIN or MAX holds a Map and the setting is builtin, it is emitted as the setting's canonical text in a quoted string instead of [('k', 'v')]. No grammar change. Custom settings are excluded, since castValueUtil returns their value unchanged and a string would come back a String.

    Covers CREATE USER/ROLE, ALTER ... SETTINGS and MIN/MAX, and additional_table_filters as well. A downgrade is safe: a pre-fix binary reads the new form correctly, so no format versioning is involved.

  5. added a commit that references this issue on Aug 14, 2026
    25224cd
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

    potential bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions