Skip to content

Report test-case state-building errors instead of raising#23002

Draft
richard-burhans wants to merge 1 commit into
galaxyproject:devfrom
richard-burhans:fix/test-case-validator-numeric-coercion-crash
Draft

Report test-case state-building errors instead of raising#23002
richard-burhans wants to merge 1 commit into
galaxyproject:devfrom
richard-burhans:fix/test-case-validator-numeric-coercion-crash

Conversation

@richard-burhans

@richard-burhans richard-burhans commented Jun 24, 2026

Copy link
Copy Markdown
Member

Fixes #23001.

validate_test_cases_for_tool_source() is meant to return a per-test validation result, but in test_case_validation() only the model validation and the unhandled-parameter-name check ran inside the try/except that records validation_error. Building the test-case state (test_case_state()) ran before it, so any failure there escaped the whole call:

  • a conditional test value that selects no when branch (Invalid conditional test value ...),
  • a non-numeric value for an integer / float parameter (legacy_from_string int() / float()),
  • other malformed test inputs handled while building state.

A caller validating tools it does not control — the 24.2 upgrade advisor, planemo / lint, CI — then aborts instead of reporting the test case as invalid.

This moves test_case_state() inside the try, so a state-building failure is captured as that test's validation_error, exactly like the existing tool_state.validate(...) failure and the "Invalid parameter name found" check. When state building fails the result falls back to an empty tool state.

Across the public Galaxy tool corpus this converts 113 of 159 tools that previously crashed the validator into reported validation errors. The remaining 46 fail earlier (during parameter-model construction or XML parsing) and are out of scope for this change.

How to test the changes?

test/unit/tool_util/test_parameter_test_cases.py::test_malformed_test_case_is_reported_not_raised builds tools with (a) a non-numeric value for an integer/float parameter and (b) a conditional test value that selects no when, and asserts the validator returns a validation_error for each instead of raising.

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

validate_test_cases_for_tool_source() is meant to return a per-test
validation result, but only model validation and the unhandled-name
check ran inside the try/except that records validation_error. Building
the test-case state (test_case_state) ran before it, so any failure
there -- an unresolvable conditional 'when' value, a non-numeric
integer/float value, a malformed repeat -- raised an unhandled exception
out of the whole call. A caller validating tools it does not control
(the 24.2 upgrade advisor, planemo/lint, CI) then aborts instead of
reporting the test case as invalid.

Move test_case_state() inside the try so a state-building failure is
captured as that test's validation_error, exactly like the existing
'Invalid parameter name found' check; fall back to an empty tool state
for the result when state-building fails.

Across the public Galaxy tool corpus this converts 113 of 159 tools that
previously crashed the validator into reported validation errors (the
remaining 46 fail earlier, during model construction or XML parsing, and
are out of scope here).

Add a regression test covering a non-numeric numeric value and an
unresolvable conditional test value.
@richard-burhans
richard-burhans force-pushed the fix/test-case-validator-numeric-coercion-crash branch from b80375e to 786712d Compare June 24, 2026 23:18
@richard-burhans richard-burhans changed the title Don't crash test-case validation on a non-numeric integer/float value Report test-case state-building errors instead of raising Jun 24, 2026
@richard-burhans

richard-burhans commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

CI has now fully settled with five failing jobs. All are in subsystems this PR does not touch — the change here is confined to galaxy.tool_util.parameters.case, and this PR's own test (tests/tool_util/test_parameter_test_cases.py::test_malformed_test_case_is_reported_not_raised) passes in the same run.

1 & 2 — Test Galaxy packages (3.10 and 3.14): collection error importing fastmcp while collecting packages/web_apps/tests/webapps/api/test_mcp.py:

fastmcp/server/context.py: from uncalled_for import SharedContext
E   ModuleNotFoundError: No module named 'uncalled_for'
E   ImportError: FastMCP server support is not installed. Install `fastmcp` or `fastmcp-slim[server]`.

A missing transitive dependency (uncalled_for) of the fastmcp version in the web_apps test environment.

3 — Converter tests (3.10): one converter, CONVERTER_cml_to_smiles (Test #1) (an OpenBabel CML→SMILES conversion); every other converter in the run passes.

4 — API tests (3.10, 1): lib/galaxy_test/api/test_workflows.py::TestWorkflowsApi::test_workflow_with_deleted_dataset_step_parameter — a workflow-API test.

5 — Integration (3.10, 3): test/integration/test_workflow_refactoring.py::TestWorkflowRefactoringIntegration::test_upgrade_all_stepsAssertionError: assert '0.1.0' == '0.1.1', a workflow tool-version assertion (1 failed, 380 passed).

None of these exercise tool test-case validation: #1#2 are a fastmcp / uncalled_for packaging issue in the web_apps test env, #3 is an OpenBabel conversion, and #4#5 are workflow-subsystem tests. Happy to rebase once the fastmcp / uncalled_for issue on dev is resolved, if that helps CI go green.

@jmchilton

Copy link
Copy Markdown
Member

Will you please merge richard-burhans#1 into this work? I think there was some concern about the broad Exception hiding actual parsing errors and I think that PR addresses some if not all of those.

@mvdbeek
mvdbeek marked this pull request as draft July 7, 2026 14:36
@mvdbeek

mvdbeek commented Jul 7, 2026

Copy link
Copy Markdown
Member

Putting this in draft while waiting for comments to be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

Test-case validation can crash instead of reporting a validation error

3 participants