Skip to content

Use ML Commons validation methods in workflow parsing#1368

Merged
dbwiddis merged 6 commits into
opensearch-project:mainfrom
dbwiddis:feature/ml-commons-field-validation
May 8, 2026
Merged

Use ML Commons validation methods in workflow parsing#1368
dbwiddis merged 6 commits into
opensearch-project:mainfrom
dbwiddis:feature/ml-commons-field-validation

Conversation

@dbwiddis
Copy link
Copy Markdown
Member

@dbwiddis dbwiddis commented Apr 21, 2026

Description

Resolves #1152.

Adds field value validation during workflow template validation (validation=all) using ML Commons StringUtils.validateFields(). This catches invalid characters in name and description fields at parse time rather than waiting for runtime provisioning failures.

Validated steps

The following ML Commons steps now have name/description validated during workflow parsing, matching the validation added in ml-commons#3805:

Step name (required) description (optional)
create_connector
register_remote_model
register_local_custom_model
register_local_sparse_encoding_model
register_local_pretrained_model
register_model_group

Changes

  • WorkflowProcessSorter.java: Added validateFieldValues() method called from validate(). Uses StringUtils.validateFields() and FieldDescriptor from ML Commons directly — no duplicated validation logic.
  • WorkflowProcessSorterTests.java: Added 4 tests covering valid inputs, invalid name, invalid description, and non-ML step passthrough.

Design decisions

  • Only validates literal string values in user inputs. Fields provided via previous_node_inputs (runtime references) are not validated at parse time.
  • Substitution template fields (e.g., ${{name}}) are also not validated, as these are resolved at provisioning time with user-supplied values.
  • Uses the same FieldDescriptor required/optional semantics as ML Commons: name is required, description is optional.
  • Error messages include the step label and node ID for easy debugging.
  • Agent and tool steps are not included because ML Commons does not yet validate those (see jngz-es comment on #3805).

How to test

# Create a workflow with an invalid connector name
POST _plugins/_flow_framework/workflow?validation=all
{
  "name": "test",
  "workflows": {
    "provision": {
      "nodes": [{
        "id": "create_connector",
        "type": "create_connector",
        "user_inputs": {
          "name": "Bad<script>Name",
          "description": "test",
          "version": "1",
          "protocol": "http",
          "parameters": {},
          "credential": {},
          "actions": []
        }
      }]
    }
  }
}
# Should return 400 with validation error about connector name

Check List

  • New functionality includes testing.
  • Commits are signed per the DCO using --signoff.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

dbwiddis added a commit to dbwiddis/flow-framework that referenced this pull request Apr 21, 2026
Signed-off-by: Dan Widdis <widdisd@amazon.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.56%. Comparing base (69f83e2) to head (5bf02ee).

Files with missing lines Patch % Lines
.../flowframework/workflow/WorkflowProcessSorter.java 90.90% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1368      +/-   ##
============================================
+ Coverage     78.38%   78.56%   +0.17%     
- Complexity     1308     1315       +7     
============================================
  Files           106      106              
  Lines          6019     6041      +22     
  Branches        641      647       +6     
============================================
+ Hits           4718     4746      +28     
+ Misses         1012     1004       -8     
- Partials        289      291       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dbwiddis added 3 commits May 1, 2026 11:30
Adds field value validation during workflow template validation using
ML Commons StringUtils.validateFields(). When validation=all is set,
name and description fields in ML Commons steps (create_connector,
register_remote_model, register_local_custom_model,
register_local_sparse_encoding_model, register_local_pretrained_model,
register_model_group) are now checked for safe characters before
provisioning.

Resolves opensearch-project#1152

Signed-off-by: Dan Widdis <widdisd@amazon.com>
Signed-off-by: Dan Widdis <widdisd@amazon.com>
Signed-off-by: Dan Widdis <widdisd@amazon.com>
@dbwiddis dbwiddis force-pushed the feature/ml-commons-field-validation branch from 522f71d to 97ab0dc Compare May 1, 2026 18:30
Signed-off-by: Daniel Widdis <widdis@gmail.com>
@dbwiddis dbwiddis merged commit 30ed527 into opensearch-project:main May 8, 2026
39 checks passed
Sign up for free to 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.

[FEATURE] Use ML Commons validation methods in Workflow parsing

2 participants