minishift: Error from server: json: cannot unmarshal string into Go value of type map[string]interface {}

Was following this guide: https://blog.openshift.com/deploying-from-private-git-repositories/

But got the following error:


> oc patch buildConfig blog-fe -p '{"spec":{"source":{"sourceSecret":{"name":"sshsecret"}}}}'
Error from server: json: cannot unmarshal string into Go value of type map[string]interface {}

Tried escaping the double quotes, but didn’t help.

I’m using Windows command line and running Minishift:

oc v3.6.0+c4dd4cf
kubernetes v1.6.1+5115d708d7
features: Basic-Auth

Server https://192.168.2.219:8443
openshift v3.6.0+c4dd4cf
kubernetes v1.6.1+5115d708d7

Update: Workaround Here

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (13 by maintainers)

Most upvoted comments

I do believe some of this could have been handled by validation by the oc client, but had some difficulty locating the sources for this command.

Edit: https://github.com/openshift/origin/blob/d539e1353f91a15ab4ef4abd7e075ae9d4b53005/pkg/oc/experimental/config/patch.go

@Slyke can you try to use double quotes for the string, instead of a single quote. And escape any other " with a back-slash like \". This makes the winning solution look as follows:

C:\> oc patch buildConfig ruby-ex -p "{\"spec\":{\"source\":{\"sourceSecret\":{\"name\":\"sshsecret\"}}}}"

Note: the command prompt wants strings to be enclosed with ", and JSON is only valid using "… so there is a trade-off to be made.

I strongly suggest this gets added in some form of documentation to this topic.