-
-
- Something went wrong when updating your notification policies.
-
-
-
- {errMessage || (
-
- Error message: "{{ error }}"
-
- )}
-
+ {errMessage}
Please refresh the page and try again.
diff --git a/public/app/features/alerting/unified/utils/k8s/errors.test.ts b/public/app/features/alerting/unified/utils/k8s/errors.test.ts
new file mode 100644
index 00000000000..ac7c03aa907
--- /dev/null
+++ b/public/app/features/alerting/unified/utils/k8s/errors.test.ts
@@ -0,0 +1,45 @@
+import {
+ ApiMachineryErrorResponse,
+ ERROR_ROUTES_MATCHER_CONFLICT,
+ getErrorMessageFromApiMachineryErrorResponse,
+} from './errors';
+
+describe('getErrorMessageFromCode', () => {
+ it(`should handle ${ERROR_ROUTES_MATCHER_CONFLICT}`, () => {
+ const error: ApiMachineryErrorResponse = {
+ status: 400,
+ config: { url: '' },
+ data: {
+ kind: 'Status',
+ apiVersion: 'v1',
+ metadata: {},
+ status: 'Failure',
+ message: 'this is ignored',
+ reason: 'BadRequest',
+ details: {
+ uid: 'alerting.notifications.routes.conflictingMatchers',
+ causes: [
+ {
+ message: '"[foo=\\"bar\\" baz=\\"qux\\"]"',
+ field: 'Matchers',
+ },
+ {
+ message: '"[foo2=\\"bar2\\" baz2=\\"qux2\\"]"',
+ field: 'Matchers',
+ },
+ ],
+ },
+ code: 400,
+ },
+ };
+
+ expect(getErrorMessageFromApiMachineryErrorResponse(error)).toBe(
+ 'Cannot add or update route: matchers conflict with an external routing tree if we merged matchers \"[foo=\\\"bar\\\" baz=\\\"qux\\\"]\", \"[foo2=\\\"bar2\\\" baz2=\\\"qux2\\\"]\". This would make the route unreachable.'
+ );
+
+ delete error.data.details?.causes;
+ expect(getErrorMessageFromApiMachineryErrorResponse(error)).toBe(
+ 'Cannot add or update route: matchers conflict with an external routing tree if we merged matchers