Skip to content

Add a value-level render assertion to the pane scope tests - #1323

Open
Paul Lizer (paullizer) wants to merge 2 commits into
microsoft:feature/admin-settings-iafrom
paullizer:admin-ia-fix-pane-scope-tests
Open

Add a value-level render assertion to the pane scope tests#1323
Paul Lizer (paullizer) wants to merge 2 commits into
microsoft:feature/admin-settings-iafrom
paullizer:admin-ia-fix-pane-scope-tests

Conversation

@paullizer

Copy link
Copy Markdown
Contributor

Test-only follow-up to #1322, which carries the actual fix. Opened from a fork because write access to the upstream branch was revoked mid-session.

Merge #1322 first — this stacks a stronger assertion on top of it.

Why

Scope analysis proves a name resolves. It does not prove the value arrives.

A pane could declare a variable locally, satisfying every check in #1322, and still derive it from the wrong place — say settings.document_action_capabilities.comparison where analyze was meant. Every scope test would pass and the wrong numbers would render.

This adds a render of the actions pane with real settings, asserting the values reach their inputs:

"analyze": {"chat_max_documents": 25, "workflow_max_documents": 250},
"comparison": {"chat_max_documents": 10, "workflow_max_documents": 100},

then asserts all four values appear in the output.

Credit where due: this assertion came from your own parallel fix of the same bug on E: — it was the one thing my version was missing.

Also

Both new test files now call assert_app_version_at_least("0.260.019"), matching the repo convention for version-aware functional tests.

Verification

CheckResult
test_admin_settings_pane_variable_scope.py4/4 pass
test_admin_settings_renders.py4/4 pass

No application code changes — tests only.

Visiting Admin Settings raised UndefinedError on analyze_capability and
returned a 500 for every request.
Root cause
Jinja {% set %} scope does not cross an {% include %} boundary. While
Admin Settings was one 14,000 line template that never mattered: a
variable derived near the top was visible everywhere below it. The
information architecture rework split it into 44 per-tab partials, and
a variable derived in one partial is not visible in another.
Three variables were left behind when their consuming card moved:
analyze_capability agents -> actions 500 error
comparison_capability agents -> actions 500 error
enable_dai_debug redis -> cosmos silent
Two failure modes, and the quiet one is worse
Attribute access on a missing name raises and takes the page down.
Loud, and found immediately.
A boolean test on a missing name is silently false, because Jinja's
default Undefined is falsy. Nothing errors. The Cosmos tab's debug
controls and shadow validation diagnostics would never have rendered,
whatever the setting was, and nothing would have reported a problem.
That one was found only by auditing for the pattern that caused the
crash.
Each declaration is a pure derivation from settings, which the route
supplies to every template, so moving it to the consuming pane is safe.
Why the existing tests missed it
Every Admin Settings test inspects the template as text: field names,
card ids, tag balance, navigation parity, modal placement. All of them
passed, because none of them execute the template.
test_admin_settings_renders.py now renders the whole page through
Jinja with the same undefined handling Flask uses, so an
UndefinedError surfaces in the suite instead of in a browser. It also
asserts every navigation tab renders a pane and that exactly one pane
is active and it is the landing tab. The context is derived from the
route's own render_template call and the app context processors, so it
cannot drift.
test_admin_settings_pane_variable_scope.py adds static scope analysis
via jinja2.meta, which catches the silent variant a render cannot,
and names the offender precisely:
'analyze_capability' is used in 'actions' but only declared in ['agents']
Both are verified against a planted copy of the real bug.
The rule: a template is not verified until it has been rendered.
Verified
page renders 1,383,741 chars, no error
tabs -> panes 44 / 44
active panes exactly 1, and it is the landing tab
field names 452 on Development, 452 here, none lost, none added
regression set 32 failures, identical to baseline
jinja compile 46/46 admin templates
xss sinks pass
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Folds in the stronger check from a parallel fix of the same bug.
Scope analysis proves a name resolves. It does not prove the value
arrives: a pane could declare a variable locally, satisfying every
scope check, and still derive it from the wrong place. Rendering the
actions pane with real settings and asserting 25, 250, 10 and 100
reach their inputs closes that gap.
Both new test files now call assert_app_version_at_least, matching the
repo convention for version-aware functional tests.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@paullizer