Skip to content

[ML] Custom rule error reason can be confusing when the detector doesn't use any fields #32542

@dolaru

Description

@dolaru

Description

Found in 6.4.0-BC1

While creating a job, if the user tries to specify scope in a custom rule even though field_name, by_field_name, over_field_name or partition_field_name, the response root cause error message is:

Invalid detector rule: scope field 'someFieldName' is invalid; select from []

Note that the error reason offers an empty list as a choice for scope fields.

A better reason should be returned instead, stating that scope cannot be specified because the detector doesn't use a field_name, by_field_name, over_field_name or partition_field_name.

Steps to reproduce

  1. Send an API request to create a job (detector with no fields and custom rule with scope specified)
PUT _xpack/ml/anomaly_detectors/custom_rule_test
{
  "analysis_config": {
    "detectors": [
      {
        "function": "count",
        "custom_rules": [
          {
            "actions": [
              "skip_result"
            ],
            "scope": {
              "someFieldName": {
                "filter_id": "someFilterId",
                "filter_type": "include"
              }
            }
          }
        ]
      }
    ]
  },
  "data_description": {}
}
  1. Notice the issue in the response root cause error reason.

Metadata

Metadata

Labels

:mlMachine learning>bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions