Skip to content

fix: guard unsubscripted Variadic type in InputSocket#11493

Open
axelray-dev wants to merge 1 commit into
deepset-ai:mainfrom
axelray-dev:fix/variadic-unsubscripted-indexerror
Open

fix: guard unsubscripted Variadic type in InputSocket#11493
axelray-dev wants to merge 1 commit into
deepset-ai:mainfrom
axelray-dev:fix/variadic-unsubscripted-indexerror

Conversation

@axelray-dev
Copy link
Copy Markdown

What's broken

Instantiating a component with a bare Annotated[Iterable, HAYSTACK_VARIADIC_ANNOTATION] annotation (no type argument) crashes with IndexError: tuple index out of range in InputSocket.__post_init__. The crash happens at component instantiation time, bypassing static type checking. For example:

def run(self, inputs: Annotated[Iterable, HAYSTACK_VARIADIC_ANNOTATION]):

raises IndexError inside get_args(get_args(self.type)[0])[0] at line 100.

Why it happens

get_args(Iterable) returns an empty tuple when the iterable has no type argument, so the unconditional [0] index fails.

Fix

Replaced the bare double-index with a guarded version that checks whether get_args() results are non-empty. When the inner type is unsubscripted, raises ComponentError with a clear message: "Variadic input 'inputs' must have a type argument, e.g. Variadic[int]."

Test

Added test_input_socket_variadic_without_type_arg_raises_component_error which creates a component with a bare Annotated[Iterable, HAYSTACK_VARIADIC_ANNOTATION] input and asserts that ComponentError is raised with the expected message.

Fixes #11453


This PR was fully generated with an AI assistant. I have reviewed the changes and run the relevant tests.

Bare Annotated[Iterable, HAYSTACK_VARIADIC_ANNOTATION] (no type argument)
caused IndexError in get_args(...)[0] on line 100. Now checks that the
inner Iterable has type args before unpacking, and raises ComponentError
with a clear message when it does not.

Fixes deepset-ai#11453
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

@axelray-dev is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@axelray-dev axelray-dev marked this pull request as ready for review June 3, 2026 01:59
@axelray-dev axelray-dev requested a review from a team as a code owner June 3, 2026 01:59
@axelray-dev axelray-dev requested review from sjrl and removed request for a team June 3, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: InputSocket.__post_init__ crashes with IndexError on unsubscripted Variadic type

1 participant