Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add index name header to all requests #272

Merged
merged 2 commits into from
Jan 29, 2025
Merged

Conversation

vicilliar
Copy link
Contributor

  • Please check if the PR fulfills these requirements
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    feature

  • What is the current behavior? (You can also link to an open issue here)
    http requests only have api key in header (if present)

  • What is the new behavior (if this is a feature change)?
    http requests send index name in header

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    no

  • Other information:

@vicilliar
Copy link
Contributor Author

Cloud integration tests: https://github.com/marqo-ai/py-marqo/actions/runs/13004448466/job/36268777672

Only 2 tests failing are due to cloud staging not being on 2.15 yet.
The other tests pass, meaning the addition of index name headers to all requests does not break existing functionality.

@@ -57,6 +56,7 @@ def send_request(
index_name: str = ""
) -> Any:
req_headers = copy.deepcopy(self.headers)
req_headers[CLOUD_INDEX_NAME_HTTP_HEADER] = index_name
Copy link
Contributor

Choose a reason for hiding this comment

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

What should we do if index_name == ""?
I'm pretty confident that it won't break anything but should we add this header in the first place if index_name argument isn't passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I'd prefer if we don't send any index name header at all in this case. This will be for requests like mq.get_indexes(). Do those need the index name header in gcp?

Copy link
Contributor

Choose a reason for hiding this comment

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

It depends, if the client was instantiated with the marqo cloud api endpoint, it is not needed, however if it is instantiated with the index endpoint directly, then yes it is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then in this case, it is better to always pass the header x-marqo-index-name: "" if no index name is provided, just so no request is missing the header.

Copy link
Collaborator

@wanliAlex wanliAlex left a comment

Choose a reason for hiding this comment

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

LGTM

@vicilliar vicilliar merged commit 59f4299 into mainline Jan 29, 2025
43 of 54 checks passed
@vicilliar vicilliar deleted the joshua/index-name-headers branch January 29, 2025 02:30
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.

3 participants