Skip to content

send_progress_in_http_headers = 1 parameter causes errors with read-only users #55

@filipealc

Description

@filipealc

Problem

When using the gem with read-only ClickHouse users, queries fail because read-only users don't have permission to use the send_progress_in_http_headers parameter. This happens because the parameter is always set when the body is not empty in the Connection#get method:

conn.params[:send_progress_in_http_headers] = 1 unless body.empty?

Impact

This prevents using the gem with read-only ClickHouse users, as they receive permission errors when attempting to execute queries.

Suggested Solution

Make the send_progress_in_http_headers parameter configurable through the gem's configuration. This would maintain backward compatibility while allowing users to disable it when needed.

Implementation suggestion:

  1. Add a configuration option to Config class:
class Config
  # ... existing attributes ...
  attr_accessor :send_progress_in_http_headers
  
  def initialize
    # ... existing initialization ...
    @send_progress_in_http_headers = true # Default to current behavior
  end
end
  1. Modify the get method in Connection class:
def get(path = '/', body: '', query: {}, database: config.database)
  # ... existing code ...

  transport.get(path) do |conn|
    conn.params = query.merge(database: database).compact
    # Only set the parameter if configured to do so and body is not empty
    if !body.empty? && config.send_progress_in_http_headers
      conn.params[:send_progress_in_http_headers] = 1
    end
    conn.body = body
  end
end
  1. Users could then configure this option:
ClickHouse.config do |config|
  # ... other configuration ...
  config.send_progress_in_http_headers = false # Disable for read-only users
end

This approach would maintain backward compatibility while solving the issue for users working with read-only ClickHouse accounts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions