Skip to content

fix: OpenSearch - do not serialize string Secrets + authentication refactoring#2967

Merged
anakin87 merged 3 commits intomainfrom
opensearch-do-not-serialize-str-secrets
Mar 19, 2026
Merged

fix: OpenSearch - do not serialize string Secrets + authentication refactoring#2967
anakin87 merged 3 commits intomainfrom
opensearch-do-not-serialize-str-secrets

Conversation

@anakin87
Copy link
Copy Markdown
Member

@anakin87 anakin87 commented Mar 17, 2026

Related Issues

Proposed Changes:

  • avoid serializing plain string Secrets
  • simplify authentication handling, similarly to Elasticsearch:
    • do not resolve Secrets in __init__ but in _ensure_initialized
    • fail if only one of username and password is provided
    • properly serialize env vars Secrets

How did you test it?

CI, new unit tests

Notes for the reviewer

To be on the safe side, I'd release a major version.
However, I saw this comment: https://github.com/deepset-ai/haystack-private/issues/268#issuecomment-4055392995

WDYT?

Checklist

@github-actions github-actions Bot added integration:opensearch type:documentation Improvements or additions to documentation labels Mar 17, 2026
@anakin87 anakin87 changed the title fix: OpenSearch - do not serialize string Secrets + refactoring fix: OpenSearch - do not serialize string Secrets + authentication refactoring Mar 17, 2026
@anakin87 anakin87 marked this pull request as ready for review March 17, 2026 11:16
@anakin87 anakin87 requested a review from a team as a code owner March 17, 2026 11:16
@anakin87 anakin87 requested review from sjrl and removed request for a team March 17, 2026 11:16
@sjrl
Copy link
Copy Markdown
Contributor

sjrl commented Mar 17, 2026

@anakin87 looking good! But I think we are missing something. I believe we also need to support dict types coming in --> basically the AWSAuth version but I'm not 100% on what this looks like.

@tstadel could you help out here and check that these changes still work with the platform?

@sjrl sjrl requested a review from tstadel March 17, 2026 14:22
@anakin87
Copy link
Copy Markdown
Member Author

I believe we also need to support dict types coming in --> basically the AWSAuth version but I'm not 100% on what this looks like.

Could you better explain?

@sjrl
Copy link
Copy Markdown
Contributor

sjrl commented Mar 18, 2026

I believe we also need to support dict types coming in --> basically the AWSAuth version but I'm not 100% on what this looks like.

Could you better explain?

Never mind took a look again at the PR and everything looks good. I think having the explicit types definitely helped me better understand the code.

Copy link
Copy Markdown
Contributor

@sjrl sjrl left a comment

Choose a reason for hiding this comment

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

So I'd say this looks all good from my point of view. It would be great if @tstadel could give it a final look over.

settings: dict[str, Any] | None = DEFAULT_SETTINGS,
create_index: bool = True,
http_auth: Any = (
http_auth: tuple[Secret, Secret] | tuple[str, str] | list[str] | str | AWSAuth | None = (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess that's fine to streamline, to be 100% accurrate better would be to also allow a callable/prototype with this signature (same as AWSAuth's call)

    def __call__(
        self,
        method: str,
        url: str,
        body: Any = None,
        headers: dict[str, str] | None = None,
    ) -> dict[str, str]:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Makes sense, but we only support the explicitly handled http_auth types via _resolve_http_auth().

Adding a generic callable would be misleading unless we also pass it through at runtime (which we don't do in the current implementation), so I'd keep the type strict for now

Copy link
Copy Markdown
Member

@tstadel tstadel left a comment

Choose a reason for hiding this comment

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

Left one small nit, to allow more custom auth (not relevant for platform).

@anakin87 anakin87 merged commit cef4925 into main Mar 19, 2026
8 checks passed
@anakin87 anakin87 deleted the opensearch-do-not-serialize-str-secrets branch March 19, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:opensearch type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants