After parsing a value an unexpected character was encountered: D. Path 'ExcludedMachineIds',

Hi folks,

I’ve recently upgraded to 3.13.6 from an older 3.x release, and am now encountering this error “intermittently” when I Create Release -> Deploy Now.

Newtonsoft.Json.JsonReaderException
   at Newtonsoft.Json.JsonTextReader.ParsePostValue()
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Octopus.Server.Web.Infrastructure.Api.Responder`1.Bind[TModel]() in Responder.cs:line 54
   at Octopus.Server.Web.Infrastructure.Api.Responder`1.BindAndValidate[TModel]() in Responder.cs:line 59
   at Octopus.Server.Web.Api.Actions.DeploymentCreateAction.Execute() in DeploymentCreateAction.cs:line 0
   at Octopus.Server.Web.Infrastructure.Api.Responder`1.Respond(TDescriptor options, NancyContext context) in Responder.cs:line 143
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Octopus.Server.Web.Api.OctopusRestApiModule.<>c__DisplayClass0_0.<.ctor>b__0(Object o) in OctopusRestApiModule.cs:line 48
   at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context)```

![2017-05-28_21_32_08-Create_deployment_-_Octopus_Deploy.png](upload://qEntuvLr9iKRmw7e0t2K7w3TLRi.png)

Hi Craig,

Thanks for getting in touch.

It’s hard to say why that is happening. How often are you seeing it?

I think the most helpful information to diagnose this would be a capture of your browser traffic to see what is being posted when the deployment is created. We find the easiest way is to use FiddlerCap (http://www.telerik.com/fiddler/fiddlercap) or your browser’s developer tools. In Chrome it would be F12 > Network. We are looking for the POST payload to /api/deployments (an example screenshot is attached).

Cheers,
Shane

Hi Shane,

Thanks for the quick response. Below is the capture from the failed POST to /api/deployments that returns a 500 response:

POST http://octopus.########.com/api/deployments HTTP/1.1
Host: octopus.########.com
Connection: keep-alive
Content-Length: 253
Accept: application/json
Origin: http://octopus.########.com
X-Octopus-User-Agent: OctopusClient-js/3.13.6
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
X-Octopus-Csrf-Token: fBrHllecpSzTWyDKtQH1aNrp6hnFePLsE2w57MKP%2foSbeT%2b5o1XPPd5udpHJaN2XJND0JBZyGDupp3f4FKwI%2b%2brVpKNefrULTYnetnJNolaEpj8kDzsxEz2wfAG%2bcAKXA4JNLdlll5OmaOjNnMuBMnM%2bORMqQf7fk50%2bBYjAltvUKj0blFA6an4eoEsP1l6eHVxFsHdSml3odziVJCcU3w%3d%3d%7cZa8MgoA69WpTaSQtEhlHzw%3d%3d
Content-type: application/json
Accept-Encoding: gzip, deflate
Accept-Language: en-AU,en-US;q=0.8,en;q=0.6
Cookie: ajs_anonymous_id=%221fbb8edb-ff83-42e6-b519-fecfa155266a%22; __qca=P0-1046174889-1483525482534; __ssid=04e3efa2-8146-4844-a157-f1724395d418; __utma=246092379.1532216171.1478815899.1494328296.1494680585.3; __utmz=246092379.1483525482.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=246092379.|1=user-type=prospect=1^2=user-category=designer=1^3=touchpoint=api=1; ajs_group_id=null; ajs_user_id=%22C9C291422E3DE149-98E40C07AD6BBC73%22; _mkto_trk=id:500-BIA-880&token:_mch-########.com-1494328296923-18050; _ga=GA1.2.1532216171.1478815899; OctopusIdentificationToken_64d81824-c1b3-4eb2-a663-c5b4021a2206=2w%2bPDoa0iohdrAySFrbJzgKGxxPTj9Jx%2bxcKAEkgCYxTiwQ754Vssbk%2bC7IdhzszTo%2fXxTdCzXIKWvsR6tO2ZwLzG5hSVeKjUO%2brkIVQf%2ftmFAcJdJrdG7mYIfdz47rJsyil6s4rnGz6fywMaCKteF8briIGRnJyUmUJzawpIzJxV5OB76QOggME5vJ3qfLrflPmWQ%2fXLwSf9bKHSMn07A%3d%3d%7c6Ii1y5d98ovdsdw6So3krQ%3d%3d; Octopus-Csrf-Token_64d81824-c1b3-4eb2-a663-c5b4021a2206=fBrHllecpSzTWyDKtQH1aNrp6hnFePLsE2w57MKP%2foSbeT%2b5o1XPPd5udpHJaN2XJND0JBZyGDupp3f4FKwI%2b%2brVpKNefrULTYnetnJNolaEpj8kDzsxEz2wfAG%2bcAKXA4JNLdlll5OmaOjNnMuBMnM%2bORMqQf7fk50%2bBYjAltvUKj0blFA6an4eoEsP1l6eHVxFsHdSml3odziVJCcU3w%3d%3d%7cZa8MgoA69WpTaSQtEhlHzw%3d%3d

{
   "ReleaseId":"Releases-1673",
   "EnvironmentId":"Environments-1",
   "TenantId":null,
   "SkipActions":[
   ],
   "QueueTime":null,
   "QueueTimeExpiry":null,
   "FormValues":{
   },
   "ForcePackageDownload":false,
   "UseGuidedFailure":false,
   "SpecificMachineIds":[
   ],
   "ExcludedMachineIds":[
   ]
}

and then despite the displayed error, if I still proceed to click “Deploy now”, the subsequent call to /api/deployments succeeds with a 201 response, and here is that request, which looks pretty darn similar:

POST http://octopus.########.com/api/deployments HTTP/1.1
Host: octopus.########.com
Connection: keep-alive
Content-Length: 253
Accept: application/json
Origin: http://octopus.########.com
X-Octopus-User-Agent: OctopusClient-js/3.13.6
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
X-Octopus-Csrf-Token: fBrHllecpSzTWyDKtQH1aNrp6hnFePLsE2w57MKP%2foSbeT%2b5o1XPPd5udpHJaN2XJND0JBZyGDupp3f4FKwI%2b%2brVpKNefrULTYnetnJNolaEpj8kDzsxEz2wfAG%2bcAKXA4JNLdlll5OmaOjNnMuBMnM%2bORMqQf7fk50%2bBYjAltvUKj0blFA6an4eoEsP1l6eHVxFsHdSml3odziVJCcU3w%3d%3d%7cZa8MgoA69WpTaSQtEhlHzw%3d%3d
Content-type: application/json
Accept-Encoding: gzip, deflate
Accept-Language: en-AU,en-US;q=0.8,en;q=0.6
Cookie: ajs_anonymous_id=%221fbb8edb-ff83-42e6-b519-fecfa155266a%22; __qca=P0-1046174889-1483525482534; __ssid=04e3efa2-8146-4844-a157-f1724395d418; __utma=246092379.1532216171.1478815899.1494328296.1494680585.3; __utmz=246092379.1483525482.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=246092379.|1=user-type=prospect=1^2=user-category=designer=1^3=touchpoint=api=1; ajs_group_id=null; ajs_user_id=%22C9C291422E3DE149-98E40C07AD6BBC73%22; _mkto_trk=id:500-BIA-880&token:_mch-########.com-1494328296923-18050; _ga=GA1.2.1532216171.1478815899; OctopusIdentificationToken_64d81824-c1b3-4eb2-a663-c5b4021a2206=2w%2bPDoa0iohdrAySFrbJzgKGxxPTj9Jx%2bxcKAEkgCYxTiwQ754Vssbk%2bC7IdhzszTo%2fXxTdCzXIKWvsR6tO2ZwLzG5hSVeKjUO%2brkIVQf%2ftmFAcJdJrdG7mYIfdz47rJsyil6s4rnGz6fywMaCKteF8briIGRnJyUmUJzawpIzJxV5OB76QOggME5vJ3qfLrflPmWQ%2fXLwSf9bKHSMn07A%3d%3d%7c6Ii1y5d98ovdsdw6So3krQ%3d%3d; Octopus-Csrf-Token_64d81824-c1b3-4eb2-a663-c5b4021a2206=fBrHllecpSzTWyDKtQH1aNrp6hnFePLsE2w57MKP%2foSbeT%2b5o1XPPd5udpHJaN2XJND0JBZyGDupp3f4FKwI%2b%2brVpKNefrULTYnetnJNolaEpj8kDzsxEz2wfAG%2bcAKXA4JNLdlll5OmaOjNnMuBMnM%2bORMqQf7fk50%2bBYjAltvUKj0blFA6an4eoEsP1l6eHVxFsHdSml3odziVJCcU3w%3d%3d%7cZa8MgoA69WpTaSQtEhlHzw%3d%3d

{
   "ReleaseId":"Releases-1673",
   "EnvironmentId":"Environments-1",
   "TenantId":null,
   "SkipActions":[
   ],
   "QueueTime":null,
   "QueueTimeExpiry":null,
   "FormValues":{
   },
   "ForcePackageDownload":false,
   "UseGuidedFailure":false,
   "SpecificMachineIds":[
   ],
   "ExcludedMachineIds":[
   ]
}

and here is the successful response:

HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
Location: /api/deployments/Deployments-1733
Server: Octopus Deploy/ Microsoft-HTTPAPI/2.0
X-UA-Compatible: IE=edge
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'none'; connect-src 'self'; font-src 'self'; img-src data: https://www.gravatar.com 'self'; script-src eval: inline: 'self' 'unsafe-eval' 'unsafe-inline'; style-src inline: 'self' 'unsafe-inline'; worker-src 'self'; block-all-mixed-content; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals;
Referrer-Policy: no-referrer
Date: Mon, 29 May 2017 12:21:28 GMT
Content-Length: 1291

{
  "Id": "Deployments-1733",
  "ReleaseId": "Releases-1673",
  "EnvironmentId": "Environments-1",
  "TenantId": null,
  "ForcePackageDownload": false,
  "ForcePackageRedeployment": false,
  "SkipActions": [],
  "SpecificMachineIds": [],
  "ExcludedMachineIds": [],
  "DeploymentProcessId": "deploymentprocess-Projects-21-s-62-P7NLK",
  "ManifestVariableSetId": "variableset-Deployments-1733",
  "TaskId": "ServerTasks-4201",
  "ProjectId": "Projects-21",
  "ChannelId": "Channels-21",
  "UseGuidedFailure": false,
  "Comments": null,
  "FormValues": {},
  "QueueTime": null,
  "QueueTimeExpiry": null,
  "Name": "Deploy to #######",
  "Created": "2017-05-29T12:21:29.136+00:00",
  "LastModifiedOn": "2017-05-29T12:21:29.171+00:00",
  "LastModifiedBy": "Craig",
  "Links": {
    "Self": "/api/deployments/Deployments-1733",
    "Release": "/api/releases/Releases-1673",
    "Environment": "/api/environments/Environments-1",
    "Project": "/api/projects/Projects-21",
    "Task": "/api/tasks/ServerTasks-4201",
    "Web": "/app#/deployments/Deployments-1733",
    "Artifacts": "/api/artifacts?regarding=Deployments-1733",
    "Interruptions": "/api/interruptions?regarding=Deployments-1733",
    "Variables": "/api/variables/variableset-Deployments-1733"
  }
}

From what I can tell the pattern seems to be every alternate call to “Deploy now” whether straight after “Create Release” or after “Try Again” following a failed deployment.

Hope this helps.

Thanks,
Craig.

Hi Craig,

I was hoping for something obvious in your first POST. I’m pretty stumped.
When you say every alternate call to “Deploy now” do you mean “Try again” -> “Deploy now” -> Deployment fails -> “Try again” -> “Deploy now” and the second “Deploy now” always fails?

Do you know if this happens from other clients? Do you have co-workers who are experiencing the same problem?

It might help to trace incoming traffic on the Octopus Server to determine if the request looks the same when it arrives.

Cheers,
Shane

Hi Shane,

The pattern seems inconsistent but it is still occurring. I traced with Wireshark on the server and it was pretty interesting to see that the closing brace in the JSON message was inverted, which is exactly what the server-side exception is complaining about…

POST /api/deployments HTTP/1.1
Host: octopus.########.com
Connection: keep-alive
Content-Length: 253
Accept: application/json
Origin: http://octopus.########.com
X-Octopus-User-Agent: OctopusClient-js/3.13.6
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
X-Octopus-Csrf-Token: fBrHllecpSzTWyDKtQH1aNrp6hnFePLsE2w57MKP%2foSbeT%2b5o1XPPd5udpHJaN2XJND0JBZyGDupp3f4FKwI%2b%2brVpKNefrULTYnetnJNolaEpj8kDzsxEz2wfAG%2bcAKXA4JNLdlll5OmaOjNnMuBMnM%2bORMqQf7fk50%2bBYjAltvUKj0blFA6an4eoEsP1l6eHVxFsHdSml3odziVJCcU3w%3d%3d%7cZa8MgoA69WpTaSQtEhlHzw%3d%3d
Content-type: application/json
Accept-Encoding: gzip, deflate
Accept-Language: en-AU,en-US;q=0.8,en;q=0.6
Cookie: ajs_anonymous_id=%221fbb8edb-ff83-42e6-b519-fecfa155266a%22; __qca=P0-1046174889-1483525482534; __ssid=04e3efa2-8146-4844-a157-f1724395d418; __utma=246092379.1532216171.1478815899.1494328296.1494680585.3; __utmz=246092379.1483525482.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=246092379.|1=user-type=prospect=1^2=user-category=designer=1^3=touchpoint=api=1; ajs_group_id=null; ajs_user_id=%22C9C291422E3DE149-98E40C07AD6BBC73%22; _mkto_trk=id:500-BIA-880&token:_mch-########.com-1494328296923-18050; _ga=GA1.2.1532216171.1478815899; OctopusIdentificationToken_64d81824-c1b3-4eb2-a663-c5b4021a2206=2w%2bPDoa0iohdrAySFrbJzgKGxxPTj9Jx%2bxcKAEkgCYxTiwQ754Vssbk%2bC7IdhzszTo%2fXxTdCzXIKWvsR6tO2ZwLzG5hSVeKjUO%2brkIVQf%2ftmFAcJdJrdG7mYIfdz47rJsyil6s4rnGz6fywMaCKteF8briIGRnJyUmUJzawpIzJxV5OB76QOggME5vJ3qfLrflPmWQ%2fXLwSf9bKHSMn07A%3d%3d%7c6Ii1y5d98ovdsdw6So3krQ%3d%3d; Octopus-Csrf-Token_64d81824-c1b3-4eb2-a663-c5b4021a2206=fBrHllecpSzTWyDKtQH1aNrp6hnFePLsE2w57MKP%2foSbeT%2b5o1XPPd5udpHJaN2XJND0JBZyGDupp3f4FKwI%2b%2brVpKNefrULTYnetnJNolaEpj8kDzsxEz2wfAG%2bcAKXA4JNLdlll5OmaOjNnMuBMnM%2bORMqQf7fk50%2bBYjAltvUKj0blFA6an4eoEsP1l6eHVxFsHdSml3odziVJCcU3w%3d%3d%7cZa8MgoA69WpTaSQtEhlHzw%3d%3d

{"ReleaseId":"Releases-1684","EnvironmentId":"Environments-1","TenantId":null,"SkipActions":[],"QueueTime":null,"QueueTimeExpiry":null,"FormValues":{},"ForcePackageDownload":false,"UseGuidedFailure":false,"SpecificMachineIds":[],"ExcludedMachineIds":[]{

with response:

HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'none'; connect-src 'self'; font-src 'self'; img-src data: https://www.gravatar.com 'self'; script-src eval: inline: 'self' 'unsafe-eval' 'unsafe-inline'; style-src inline: 'self' 'unsafe-inline'; worker-src 'self'; block-all-mixed-content; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals;
Referrer-Policy: no-referrer
Date: Sun, 04 Jun 2017 12:30:49 GMT

{
  "ErrorMessage": "After parsing a value an unexpected character was encountered: {. Path 'ExcludedMachineIds', line 1, position 252.",
  "FullException": "After parsing a value an unexpected character was encountered: {. Path 'ExcludedMachineIds', line 1, position 252.\r\nNewtonsoft.Json.JsonReaderException\r\n   at Newtonsoft.Json.JsonTextReader.ParsePostValue()\r\n   at Newtonsoft.Json.JsonTextReader.Read()\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n   at Octopus.Server.Web.Infrastructure.Api.Responder`1.Bind[TModel]() in Responder.cs:line 54\r\n   at Octopus.Server.Web.Infrastructure.Api.Responder`1.BindAndValidate[TModel]() in Responder.cs:line 59\r\n   at Octopus.Server.Web.Api.Actions.DeploymentCreateAction.Execute() in DeploymentCreateAction.cs:line 0\r\n   at Octopus.Server.Web.Infrastructure.Api.Responder`1.Respond(TDescriptor options, NancyContext context) in Responder.cs:line 143\r\n   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)\r\n   at Octopus.Server.Web.Api.OctopusRestApiModule.<>c__DisplayClass0_0.<.ctor>b__0(Object o) in OctopusRestApiModule.cs:line 48\r\n   at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context)"
}

I suspect you will be similarly stumped as I am, so unless anything leaps out then I’ll continue to look for a pattern of use and/or environment permutation that might help isolate the cause and get back to you if I can nail it down. At the very least, it will be a reference if anyone else should encounter this down the track.

Thanks for your help,
Craig.

Hi Craig,

If the client is sending the correct request but the server is receiving something different there must be something in between? Is there a proxy or browser plugin or…?

Does it only happen when creating a deployment?

I’ve run this past the team and we are all scratching our heads, will be interested to find out what it is.

Cheers,
Shane

Ok thanks Shane, appreciate you and the team looking into it.

I have IIS rewriting URL’s on the server to coexist with TeamCity on port 80, though I’ve had that setup working and unchanged for a couple of years. Maybe something in the XHR request/response from the more recent version of Octopus Deploy is now tripping it up.

Will post back here if I get to the bottom of it.
Craig.