Bug 2026297

Summary: Use '&' (ampersand) in environment variables of oc start-build in Openshift 4.6
Product: OpenShift Container Platform Reporter: JS <josantos>
Component: BuildAssignee: Otávio Fernandes <olemefer>
Status: CLOSED DUPLICATE QA Contact: Jitendar Singh <jitsingh>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.6.zCC: aos-bugs, eparis, gmontero, irum, jokerman, mfojtik, pbhattac, spandura
Target Milestone: ---   
Target Release: 4.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-01-06 13:29:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description JS 2021-11-24 10:16:58 UTC
Description of problem:
Using oc start-build with environment variables that contains '&' will be encoded to \u0026

Version-Release number of selected component (if applicable):
Tested and confirmed on OCP 4.6:
- 4.6.27
- 4.6.49

How reproducible:
Always

Steps to Reproduce:
1. Create a new namespace `$ oc new-project namespace-dev`
2. Start a dummy out of box app `$ oc new-app https://github.com/openshift/ruby-hello-world --name=ruby-hello`
3. Start a build with environment variables `$oc start-build ruby-hello --env=ARTIFACT_URL='http://some.url.com/with?query=params&second=param' --env=ARTIFACT_URL_02='http&'`
4. Check the environment variables from the new generated POD `$ oc rsh <POD> env | grep ARTIFACT_URL`

Actual results:
From OCP 4.6.z

```
$ oc rsh ruby-hello-546cff6d5b-jk48h env | grep ARTIFACT_URL
ARTIFACT_URL=http://some.url.com/with?query=params\u0026second=param
ARTIFACT_URL_02=http\u0026
```

Expected results:
From OCP 4.7.11

```
$ oc rsh pod/ruby-hello-8f69774d4-bs9jv env | grep ARTIFACT_URL
ARTIFACT_URL=http://some.url.com/with?query=params&second=param
ARTIFACT_URL_02=http&
```

Additional info:
- Not all apps will know how to convert `\u0026`

Comment 1 Maciej Szulik 2021-11-30 15:51:56 UTC
Moving to build team who owns that bit of oc.

Comment 4 Otávio Fernandes 2022-01-06 13:29:04 UTC
Given the issue only happens in 4.6, it's too late for back-porting at this point. Therefore closing this BZ.

I have tested the solution applied in 4.7, back ported to 4.6 via this "draft"  pull-request: https://github.com/openshift/builder/pull/278 . The experiment shows it fixes the issue back in 4.6 as well.

*** This bug has been marked as a duplicate of bug 1918153 ***

Comment 5 Gabe Montero 2022-01-06 15:18:54 UTC
As a reminder to everyone watching this bz, the support dates for 4.x are at  https://access.redhat.com/support/policy/updates/openshift#dates and the state of 4.6.z that Otavio alluded to in #Comment 4 is noted there