Description of problem: Then the JSON value of the environment variable contains escaped quotes the build pod's interpolation causes failures while unmarshaling the JSON data. Version-Release number of selected component (if applicable): 4.7 How reproducible: kind: ImageStream apiVersion: v1 metadata: name: output --- apiVersion: v1 kind: BuildConfig metadata: name: output spec: output: to: kind: ImageStreamTag name: output:latest source: dockerfile: | FROM registry.ci.openshift.org/openshift/release:golang-1.16 RUN echo $'package main\nimport "encoding/json"\nimport "os"\nimport "fmt"\ntype data struct{\n Title string\n}\nfunc main() {\n fmt.Println(os.Getenv("DATA")) \n var d data\n if err := json.Unmarshal([]byte(os.Getenv("DATA")), &d); err != nil {\n panic(err)\n } else {\n fmt.Println(d.Title)\n }\n}' > read.go RUN cat read.go RUN go run read.go strategy: dockerStrategy: from: kind: DockerImage name: registry.ci.openshift.org/openshift/release:golang-1.16 imageOptimizationPolicy: SkipLayers env: - name: DATA value: "{\"title\":\"Revert \\\"Wait for expected number of drivers starting API\\\"\"}"
Notably, we pass in: > "{\"title\":\"Revert \\\"Wait for expected number of drivers starting API\\\"\"}" As the value. By the time the Go program reads it, this looks like: > {"title":"Revert \\"Wait for expected number of drivers starting API\\""} On a normal system: $ DATA="{\"title\":\"Revert \\\"Wait for expected number of drivers starting API\\\"\"}" $ echo $DATA {"title":"Revert \"Wait for expected number of drivers starting API\""}
@nmoraiti Can you verify what the value of the env var looks like in the build yaml? And I am guessing that you were able to rsh into the build pod to get the referenced output above for the value of the `DATA` env var?
This seems fixed in 4.8.0-rc.1
verified
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (OpenShift Container Platform 4.8.14 bug fix update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2021:3682
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 500 days