File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
src/WebJobs.Script/OutOfProc/Rpc
test/WebJobs.Script.Tests/Rpc Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -225,7 +225,11 @@ internal FunctionEnvironmentReloadRequest GetFunctionEnvironmentReloadRequest(ID
225
225
FunctionEnvironmentReloadRequest request = new FunctionEnvironmentReloadRequest ( ) ;
226
226
foreach ( DictionaryEntry entry in processEnv )
227
227
{
228
- request . EnvironmentVariables . Add ( entry . Key . ToString ( ) , entry . Value . ToString ( ) ) ;
228
+ // Do not add environment variables with empty or null values (see issue #4488 for context)
229
+ if ( ! string . IsNullOrEmpty ( entry . Value ? . ToString ( ) ) )
230
+ {
231
+ request . EnvironmentVariables . Add ( entry . Key . ToString ( ) , entry . Value . ToString ( ) ) ;
232
+ }
229
233
}
230
234
return request ;
231
235
}
Original file line number Diff line number Diff line change @@ -214,10 +214,14 @@ public async Task SendSendFunctionEnvironmentReloadRequest_ThrowsTimeout()
214
214
[ Fact ]
215
215
public void SendSendFunctionEnvironmentReloadRequest_SanitizedEnvironmentVariables ( )
216
216
{
217
- Environment . SetEnvironmentVariable ( "TestNull" , null ) ;
218
- Environment . SetEnvironmentVariable ( "TestEmpty" , string . Empty ) ;
219
- Environment . SetEnvironmentVariable ( "TestValid" , "TestValue" ) ;
220
- FunctionEnvironmentReloadRequest envReloadRequest = _workerChannel . GetFunctionEnvironmentReloadRequest ( Environment . GetEnvironmentVariables ( ) ) ;
217
+ var environmentVariables = new Dictionary < string , string > ( )
218
+ {
219
+ { "TestNull" , null } ,
220
+ { "TestEmpty" , string . Empty } ,
221
+ { "TestValid" , "TestValue" }
222
+ } ;
223
+
224
+ FunctionEnvironmentReloadRequest envReloadRequest = _workerChannel . GetFunctionEnvironmentReloadRequest ( environmentVariables ) ;
221
225
Assert . False ( envReloadRequest . EnvironmentVariables . ContainsKey ( "TestNull" ) ) ;
222
226
Assert . False ( envReloadRequest . EnvironmentVariables . ContainsKey ( "TestEmpty" ) ) ;
223
227
Assert . True ( envReloadRequest . EnvironmentVariables . ContainsKey ( "TestValid" ) ) ;
You can’t perform that action at this time.
0 commit comments