Description
Package: agent-framework-declarative
Component: DeclarativeWorkflowState.eval() in _declarative_base.py
Affected versions: ≤ 1.0.0b260225
On machines where the UI locale is not English (e.g. it-IT, fr-FR,
de-DE), evaluating a Power Fx expression that references an as-yet-unset
state variable raises an unhandled ValueError and crashes the entire workflow,
instead of returning None gracefully.
This makes patterns like the following impossible:
-- Local.StatusConversationId is undefined --
- kind: InvokeAzureAgent
conversationId: =Local.StatusConversationId # crashes on non-EN locale
...
the =Local.StatusConversationId
expression crashes before the value can be read.
Root Cause
eval() already contains a guard to handle undefined-variable errors gracefully:
except ValueError as e:
error_msg = str(e)
if "isn't recognized" in error_msg or "Name isn't valid" in error_msg:
return None # treat missing variable as None
raise
The guard matches against English Power Fx error strings. However,
errors are produced in the language determined by
CultureInfo.CurrentUICulture — not CurrentCulture. The existing code
forced CurrentCulture to "en-US" before calling the engine, but left
CurrentUICulture unchanged. On an Italian system this yields:
ValueError: Power Fx failed compilation:
Il nome non è valido. "StatusConversationId" non riconosciuto.
…which matches neither "isn't recognized" nor "Name isn't valid", so the
exception propagates and the workflow terminates with an unhandled traceback.
Steps to Reproduce
- Run any declarative workflow that uses
=Local.<Variable> in an expression
on a machine whose UI culture is not en-US (e.g. set
LANG=it_IT.UTF-8 or run on an Italian macOS/Windows installation).
- Ensure the variable is set before the expression is evaluated (to confirm
the variable itself is not the issue, but merely the locale of the error
message).
Fix
In _declarative_base.py, force both CurrentCulture and
CurrentUICulture to "en-US" before calling the Power Fx engine, and restore
both in the finally block:
original_culture = CultureInfo.CurrentCulture
original_ui_culture = CultureInfo.CurrentUICulture # ← add
CultureInfo.CurrentCulture = CultureInfo("en-US")
CultureInfo.CurrentUICulture = CultureInfo("en-US") # ← add
try:
return engine.eval(formula, symbols=symbols)
finally:
CultureInfo.CurrentCulture = original_culture
CultureInfo.CurrentUICulture = original_ui_culture # ← add
Code Sample
Error Messages / Stack Traces
Package Versions
1.0.0b260225
Python Version
3.12
Additional Context
No response
Description
Package: agent-framework-declarative
Component: DeclarativeWorkflowState.eval() in _declarative_base.py
Affected versions: ≤ 1.0.0b260225
On machines where the UI locale is not English (e.g.
it-IT,fr-FR,de-DE), evaluating a Power Fx expression that references an as-yet-unsetstate variable raises an unhandled
ValueErrorand crashes the entire workflow,instead of returning
Nonegracefully.This makes patterns like the following impossible:
-- Local.StatusConversationId is undefined --
the
=Local.StatusConversationIdexpression crashes before the value can be read.
Root Cause
eval()already contains a guard to handle undefined-variable errors gracefully:The guard matches against English Power Fx error strings. However,
errors are produced in the language determined by
CultureInfo.CurrentUICulture— notCurrentCulture. The existing codeforced
CurrentCultureto"en-US"before calling the engine, but leftCurrentUICultureunchanged. On an Italian system this yields:…which matches neither
"isn't recognized"nor"Name isn't valid", so theexception propagates and the workflow terminates with an unhandled traceback.
Steps to Reproduce
=Local.<Variable>in an expressionon a machine whose UI culture is not
en-US(e.g. setLANG=it_IT.UTF-8or run on an Italian macOS/Windows installation).the variable itself is not the issue, but merely the locale of the error
message).
Fix
In
_declarative_base.py, force bothCurrentCultureandCurrentUICultureto"en-US"before calling the Power Fx engine, and restoreboth in the
finallyblock:Code Sample
Error Messages / Stack Traces
Package Versions
1.0.0b260225
Python Version
3.12
Additional Context
No response