hashicorp / hashicorp/vault-client-dotnet

BuildUserAgent function throws error when OS name is single worded in etc/os-release

Open
#205 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
48
Forks
6
PR merge metrics
No merged PRs in 30d

Description

# Expected Behavior

Should also support single worded `PRETTY_NAME="Chainguard"` in `/etc/os-release`. As per [this](https://www.freedesktop.org/software/systemd/man/latest/os-release.html#PRETTY_NAME=) the pretty name may or may not contain a release code name or OS version.

# Current Behavior

Currently it only supports if there are multiple words in `PRETTY_NAME=Debian GNU/LINUX 12"`

# Failure Information
`System.ArgumentOutOfRangeException` because it's not able to find space in OS description [here](https://github.com/hashicorp/vault-client-dotnet/blob/8b203fdbfdb865f7ee148d1b9d003abc935bcfbf/src/Vault/Client/Configuration.cs#L341)

Vault 1.16.1
Vault C# Client 0.3.0

## Steps to Reproduce

1. Update PRETTY_NAME in /etc/os-release to a single worded name (found this issue when I used a dotnet chainguard image where the pretty name is just one word `Chainguard`)
2. call VaultConfiguration()

# Additional Information

```
Unhandled exception. System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.
at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName)
at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
at System.String.Substring(Int32 startIndex, Int32 length)
at Vault.Client.VaultConfiguration.BuildUserAgent()
at Vault.Client.VaultConfiguration..ctor(String basePath, HttpClientHandler httpClientHandler, Nullable`1 timeout, RetryConfiguration retryConfiguration, RateLimitConfiguration rateLimitConfiguration, TLSConfiguration tlsConfiguration)
at VaultAdapter..ctor(IOptions`1 options)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.