Skip to content

Conversation

@Alikberova
Copy link

@Alikberova Alikberova commented Dec 12, 2025

Change GetValues to TryGetValues in TextToSpeechEndpoint

The given header was not found
at System.Net.Http.Headers.HttpHeaders.GetValues(HeaderDescriptor descriptor)
at ElevenLabs.TextToSpeech.TextToSpeechEndpoint.<TextToSpeechAsync>d__7.MoveNext()

@StephenHodgson
Copy link
Member

@Alikberova what exactly is this trying to fix? We need this header since it gives us metadata about the history item id

@StephenHodgson StephenHodgson marked this pull request as draft December 20, 2025 21:09
@Alikberova
Copy link
Author

@Alikberova what exactly is this trying to fix? We need this header since it gives us metadata about the history item id

the exception was The given header was not found coming from HttpHeaders.GetValues method.
This method throws error if the HistoryItemId header is missing.

Seems this behavior is not expected in the code flow giving that code is checking for IsNullOrWhiteSpace.
If the clipId is null, this if statement never be reached as GetValues throws exception.

var clipId = response.Headers.GetValues(HistoryItemId).FirstOrDefault();

if (string.IsNullOrWhiteSpace(clipId))
{
    throw new ArgumentException("Failed to parse clip id!");
}

The fix ensures that, when the header is missing, the code throws the intended error message Failed to parse clip id! instead of the generic HttpHeaders exception.

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