Skip to content

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

Description

@shettyprathik

Expected Behavior

Should also support single worded PRETTY_NAME="Chainguard" in /etc/os-release. As per this 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

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions