Skip to content

feat: Add support for custom headers#1162

Merged
joein merged 3 commits into
devfrom
custom-headers
Mar 13, 2026
Merged

feat: Add support for custom headers#1162
joein merged 3 commits into
devfrom
custom-headers

Conversation

@Anush008

@Anush008 Anush008 commented Mar 4, 2026

Copy link
Copy Markdown
Member

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you installed pre-commit with pip3 install pre-commit and set up hooks with pre-commit install?

@netlify

netlify Bot commented Mar 4, 2026

Copy link
Copy Markdown

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 30f11a1
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/69b42300482fa700071e4904
😎 Deploy Preview https://deploy-preview-1162--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Mar 4, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3b245478-b60c-4789-859f-4ca500047411

📥 Commits

Reviewing files that changed from the base of the PR and between a95a529 and 93ce357.

📒 Files selected for processing (2)
  • qdrant_client/async_qdrant_remote.py
  • qdrant_client/qdrant_remote.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • qdrant_client/qdrant_remote.py
  • qdrant_client/async_qdrant_remote.py

📝 Walkthrough

Walkthrough

Adds an optional headers: dict[str, str] | None parameter to constructors of QdrantClient, AsyncQdrantClient, QdrantRemote, and AsyncQdrantRemote. Provided headers are merged into REST headers and appended to gRPC metadata during initialization. The change forwards headers through client construction, computes and enforces a builtin User-Agent, and emits warnings if provided api-key, User-Agent, or grpc.primary_user_agent values would be overridden.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'feat: Add support for custom headers' clearly and concisely summarizes the main change in the changeset, which adds a headers parameter across multiple client classes.
Description check ✅ Passed The pull request description is a standard submission checklist that confirms the contributor has followed guidelines, created tests, and set up pre-commit hooks, all related to the feature submission.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch custom-headers
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
qdrant_client/async_qdrant_client.py (1)

107-112: headers will be stored in init_options (consistent with existing sensitive params).

Custom headers (which may contain sensitive values like authentication tokens) are captured in _init_options and exposed via the public init_options property. This is consistent with how api_key and auth_token_provider are already handled.

No change is required, but users should be aware that init_options may contain sensitive data and should not be logged or serialized without redaction.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@qdrant_client/async_qdrant_client.py` around lines 107 - 112, The constructor
currently stores the incoming headers parameter in self._init_options which is
exposed via the public init_options property, so sensitive header values (e.g.,
auth tokens) can leak if init_options is logged or serialized; either avoid
exposing raw headers by removing or redacting the "headers" key from
self._init_options before assignment or implement redaction in the init_options
property getter (reference symbols: the constructor that populates
_init_options, the _init_options dict itself, and the public init_options
property) and ensure any logging or serialization paths use the redacted form.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@qdrant_client/async_qdrant_remote.py`:
- Around line 120-123: The headers merge currently applies user-provided headers
before the client sets "api-key" and "User-Agent", which silently overwrites
user values; update the merging logic in the async_qdrant_remote constructor
(the block that writes to self._rest_headers and self._grpc_headers) to
explicitly handle reserved keys: define a reserved set containing "api-key" and
"User-Agent" and either (A) prevent overrides by checking headers for any
reserved keys and raising a clear ValueError if present, or (B) allow overrides
by applying user headers after the client sets its defaults (i.e., set defaults
first then merge headers), and add matching behavior to the synchronous
implementation; also update the parameter docstring to state the chosen behavior
for reserved headers.

---

Nitpick comments:
In `@qdrant_client/async_qdrant_client.py`:
- Around line 107-112: The constructor currently stores the incoming headers
parameter in self._init_options which is exposed via the public init_options
property, so sensitive header values (e.g., auth tokens) can leak if
init_options is logged or serialized; either avoid exposing raw headers by
removing or redacting the "headers" key from self._init_options before
assignment or implement redaction in the init_options property getter (reference
symbols: the constructor that populates _init_options, the _init_options dict
itself, and the public init_options property) and ensure any logging or
serialization paths use the redacted form.

ℹ️ Review info
Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2406679c-962f-42c5-a86a-fa49c0f32aa0

📥 Commits

Reviewing files that changed from the base of the PR and between 63f6954 and a95a529.

📒 Files selected for processing (4)
  • qdrant_client/async_qdrant_client.py
  • qdrant_client/async_qdrant_remote.py
  • qdrant_client/qdrant_client.py
  • qdrant_client/qdrant_remote.py

Comment thread qdrant_client/async_qdrant_remote.py
@Anush008 Anush008 requested review from generall and joein March 4, 2026 10:38
@joein joein self-requested a review March 12, 2026 18:12
@joein joein merged commit c7a5bef into dev Mar 13, 2026
12 checks passed
joein added a commit that referenced this pull request Mar 13, 2026
* feat: Add support for custom headers

Signed-off-by: Anush008 <[email protected]>

* add warnings when user provides user-agent or api-key in headers or options

* fix: fix is none condition

---------

Signed-off-by: Anush008 <[email protected]>
Co-authored-by: George Panchuk <[email protected]>
@Anush008 Anush008 deleted the custom-headers branch March 14, 2026 04:11
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.

2 participants