`JsonException` with Release `1.1.0` when using `VSS_NUGET_EXTERNAL_FEED_ENDPOINTS`
sailro opened this issue · 4 comments
Hello,
Starting with 1.1.0
, the credential provider is now using System.Text.Json
instead of NewtonSoft.Json
.
But this can lead to breaking changes, as in the example below:
We were using docker images like this:
ARG nugetFeedEndpointCredentials
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS=$nugetFeedEndpointCredentials
RUN \
wget --quiet https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh \
&& chmod +x installcredprovider.sh \
&& ./installcredprovider.sh
And using them in our AZDO build pipeline (see how we are using single quotes for endpointCredentials
):
- script: |
docker [...] --build-arg nugetFeedEndpointCredentials="{'endpointCredentials':[{'endpoint':'https://foo/bar/_packaging/baz','username':'optional','password':'$(System.AccessToken)'}]}"
As soon as the 1.1.0
was published we hit:
[NuGet Manager] [Error] [CredentialProvider]Failed to acquire session token: System.Text.Json.JsonException: ''' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: 0 | BytePositionInLine: 1.
Indeed single quotes around string values are not supported by design in System.Text.Json
.
System.Text.Json only accepts property names and string values in double quotes because that format is required
by the RFC 8259 specification and is the only format considered valid JSON.
A value enclosed in single quotes results in a `JsonException` with the message: ''' is an invalid start of a value.
Of course we can fix this by using double-quotes going forward, but this change will probably break several users.
As an immediate workaround, before analyzing the issue we used:
ENV AZURE_ARTIFACTS_CREDENTIAL_PROVIDER_VERSION=v1.0.9
in our docker files to rollback to 1.0.9
.
Regards
Seb
Thank you for the tip, the workaround solved the issue.
It's frustrating that we have to modify all of our Dockerfiles now.
We were affected by this too: we pass the value by means of a variable group so we had to change only the single variable.
Apologies for the breaking change. A new 1.1.1 release to revert has been created and set as latest.
We would like to use System.Text.Json in future versions and env variables with single quotes will need to be updated.
Apologies for the breaking change. A new 1.1.1 release to revert has been created and set as latest.
We would like to use System.Text.Json in future versions and env variables with single quotes will need to be updated.
Thank you for the quick reaction, the grace period is appreciated.