Skip to content

Commit

Permalink
Mark connector param validation failures as user errors (elastic#197812)
Browse files Browse the repository at this point in the history
Resolves elastic/response-ops-team#255

In this PR, I'm changing the type of error thrown when connector
parameter validation fails so it indicates it's a user type of error.
This will allow us to exclude these errors from our serverless
monitoring given the users define the parameters the connectors receive
when they run. Mainly via alerting rule mustache templates, which are
easy to render empty strings and such.
  • Loading branch information
mikecote authored Oct 25, 2024
1 parent ae9c0d3 commit c8be1e2
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 44 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/lib/action_executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ describe('Action Executor', () => {
status: 'error',
retry: false,
message: `error validating action params: [param1]: expected value of type [string] but got [undefined]`,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});

Expand Down
11 changes: 11 additions & 0 deletions x-pack/plugins/actions/server/lib/action_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,17 @@ function validateAction(

try {
validatedParams = validateParams(actionType, params, validatorServices);
} catch (err) {
throw new ActionExecutionError(err.message, ActionExecutionErrorReason.Validation, {
actionId,
status: 'error',
message: err.message,
retry: !!taskInfo,
errorSource: TaskErrorSource.USER,
});
}

try {
validatedConfig = validateConfig(actionType, config, validatorServices);
validatedSecrets = validateSecrets(actionType, secrets, validatorServices);
if (actionType.validate?.connector) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default function bedrockTest({ getService }: FtrProviderContext) {
message:
'error validating action params: [subAction]: expected value of type [string] but got [undefined]',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});

Expand Down Expand Up @@ -620,7 +620,7 @@ export default function bedrockTest({ getService }: FtrProviderContext) {
expect(body).to.eql({
status: 'error',
connector_id: bedrockActionId,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
message:
'error validating action params: [subAction]: expected value of type [string] but got [undefined]',
retry: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default function casesWebhookTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: [subAction]: expected value to equal [pushToService]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand All @@ -291,7 +291,7 @@ export default function casesWebhookTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: [subActionParams.incident.title]: expected value of type [string] but got [undefined]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand All @@ -318,7 +318,7 @@ export default function casesWebhookTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: [subActionParams.incident.title]: expected value of type [string] but got [undefined]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down Expand Up @@ -347,7 +347,7 @@ export default function casesWebhookTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: [subActionParams.comments]: types that failed validation:\n- [subActionParams.comments.0.0.commentId]: expected value of type [string] but got [undefined]\n- [subActionParams.comments.1]: expected value to equal [null]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down Expand Up @@ -375,7 +375,7 @@ export default function casesWebhookTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: [subActionParams.comments]: types that failed validation:\n- [subActionParams.comments.0.0.comment]: expected value of type [string] but got [undefined]\n- [subActionParams.comments.1]: expected value to equal [null]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default function d3SecurityTest({ getService }: FtrProviderContext) {
message:
'error validating action params: [subAction]: expected value of type [string] but got [undefined]',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});

Expand Down Expand Up @@ -311,7 +311,7 @@ export default function d3SecurityTest({ getService }: FtrProviderContext) {
message:
'error validating action params: [subAction]: expected value of type [string] but got [undefined]',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export default function geminiTest({ getService }: FtrProviderContext) {
message:
'error validating action params: [subAction]: expected value of type [string] but got [undefined]',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});

Expand Down Expand Up @@ -378,7 +378,7 @@ export default function geminiTest({ getService }: FtrProviderContext) {
message:
'error validating action params: [subAction]: expected value of type [string] but got [undefined]',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default function jiraTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subAction]: expected value to equal [pushToService]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand All @@ -281,7 +281,7 @@ export default function jiraTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.incident.summary]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand All @@ -308,7 +308,7 @@ export default function jiraTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.incident.summary]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down Expand Up @@ -337,7 +337,7 @@ export default function jiraTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.commentId]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down Expand Up @@ -365,7 +365,7 @@ export default function jiraTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.comment]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down Expand Up @@ -394,7 +394,7 @@ export default function jiraTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.incident.labels]: types that failed validation:\n - [subActionParams.incident.labels.0.0]: The label label with spaces cannot contain spaces\n - [subActionParams.incident.labels.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down Expand Up @@ -430,7 +430,7 @@ export default function jiraTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.incident.otherFields]: types that failed validation:\n - [subActionParams.incident.otherFields.0]: A maximum of 20 fields in otherFields can be defined at a time.\n - [subActionParams.incident.otherFields.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down Expand Up @@ -461,7 +461,7 @@ export default function jiraTest({ getService }: FtrProviderContext) {
retry: false,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.incident.otherFields]: types that failed validation:\n - [subActionParams.incident.otherFields.0.key("summary")]: The following properties cannot be defined inside otherFields: summary.\n - [subActionParams.incident.otherFields.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]',
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default function genAiTest({ getService }: FtrProviderContext) {
message:
'error validating action params: [subAction]: expected value of type [string] but got [undefined]',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});

Expand Down Expand Up @@ -483,7 +483,7 @@ export default function genAiTest({ getService }: FtrProviderContext) {
message:
'error validating action params: [subAction]: expected value of type [string] but got [undefined]',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export default function serviceNowITOMTest({ getService }: FtrProviderContext) {
connector_id: simulatedActionId,
status: 'error',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [addEvent]\n- [1.subAction]: expected value to equal [getChoices]',
});
Expand All @@ -459,7 +459,7 @@ export default function serviceNowITOMTest({ getService }: FtrProviderContext) {
connector_id: simulatedActionId,
status: 'error',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [addEvent]\n- [1.subAction]: expected value to equal [getChoices]',
});
Expand All @@ -482,7 +482,7 @@ export default function serviceNowITOMTest({ getService }: FtrProviderContext) {
connector_id: simulatedActionId,
status: 'error',
retry: false,
errorSource: TaskErrorSource.FRAMEWORK,
errorSource: TaskErrorSource.USER,
message:
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [addEvent]\n- [1.subActionParams.fields]: expected value of type [array] but got [undefined]',
});
Expand Down
Loading

0 comments on commit c8be1e2

Please sign in to comment.