[App Service] az functionapp deployment source config-zip: Fix KeyError 'FUNCTIONS_WORKER_RUNTIME' for Go on Flex Consumption#33404
Conversation
…rror 'FUNCTIONS_WORKER_RUNTIME' for Go on Flex Consumption Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Hi @harshivcodes, |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this comment.
Pull request overview
Fixes a crash in the App Service Function App “Flex Consumption” runtime stack parser where Go stacks may return an empty appSettingsDictionary, causing a KeyError when reading FUNCTIONS_WORKER_RUNTIME. This unblocks az functionapp deployment source config-zip (and other az functionapp flows that use _FlexFunctionAppStackRuntimeHelper) for Go apps on Flex Consumption.
Changes:
- Make
_FlexFunctionAppStackRuntimeHelper._parse_raw_stackssafely readFUNCTIONS_WORKER_RUNTIMEvia nested.get()with fallback toruntime['name']. - Add regression tests covering (1) empty
appSettingsDictionary(Go shape) and (2) preferringFUNCTIONS_WORKER_RUNTIMEwhen present (e.g., dotnet-isolated).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/appservice/custom.py |
Prevents KeyError by using .get() to read FUNCTIONS_WORKER_RUNTIME, preserving existing fallback behavior. |
src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_functionapp_commands_thru_mock.py |
Adds mocked regression tests for the empty-dictionary case and for the precedence of FUNCTIONS_WORKER_RUNTIME. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Related command
az functionapp deployment source config-zip(Also affects every other
az functionappcommand that goes through_FlexFunctionAppStackRuntimeHelper:functionapp create,functionapp config setfor runtime,functionapp list-flexconsumption-runtimes,functionapp list-flexconsumption-locations,functionapp deployment github-actions add,functionapp flex-migration.)Description
az functionapp deployment source config-zipcrashes withKeyError: 'FUNCTIONS_WORKER_RUNTIME'for every Go function app on Flex Consumption, before any zip is uploaded. The crash is in_FlexFunctionAppStackRuntimeHelper._parse_raw_stacksatcustom.py:7771:The intent is to prefer
FUNCTIONS_WORKER_RUNTIMEbut fall back toruntime['name']when FWR isn't set. But the dictionary access is hard-indexed instead of using.get(), so Python raisesKeyErrorbefore theorfallback can execute.This is fine for node/python/java/powershell/dotnet — their stack definitions populate
appSettingsDictionary.FUNCTIONS_WORKER_RUNTIMEin the API response. It breaks for Go because Flex Consumption Go apps deliberately returnappSettingsDictionary: {}(Go on Flex doesn't require FWR on the app at runtime — native binaries, no managed worker). The Go stack definition isn't introducing this bug; it's exposing a latent over-assumption in the CLI parser that was hidden only because every prior Flex language happened to populate FWR.Fix: change the chained
[ ]lookup to use.get()so the existingor runtime['name']fallback can run. This matches the defensive pattern already used by the sibling Windows/Linux helper_FunctionAppStackRuntimeHelper._parse_minor_versionin the same file.For Go,
runtime['name']resolves to"go", the stack registers as"go", and downstreamresolve("go")matches the deployed app'sfunctionAppConfig.runtime.name == "go"cleanly. Other languages are unaffected — their FWR value is truthy, soorshort-circuits before the fallback.Testing Guide
test_flex_parse_raw_stacks_handles_empty_app_settings_dictionary— feeds a Go-shaped stack withappSettingsDictionary: {}and assertsresolve('go', '1.0')returns a runtime named"go"(this test fails on the currentdevbranch withKeyError).test_flex_parse_raw_stacks_prefers_functions_worker_runtime_when_present— feeds adotnet-isolatedstack and asserts FWR overridesruntime['name'](preserves canonical-name semantics).History Notes
[App Service]
az functionapp deployment source config-zip: FixKeyError'FUNCTIONS_WORKER_RUNTIME'for Go function apps on Flex Consumption