---
policy: /ce/ca/aws/opensearch/domain-error-logging
logic: /ce/ca/aws/opensearch/domain-error-logging/prod.logic.yaml
executionTime: 2025-12-27T12:02:05.820814243Z
generationMs: 281
executionMs: 849
rows:
  - id: test1
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10__disappearanceTime__c)
      actual: isDisappeared(CA10__disappearanceTime__c)
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__logPublishingOptionsJson__c').isEmpty()
      actual: extract('CA10__logPublishingOptionsJson__c').isEmpty()
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: not(extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled'))
      actual: not(extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled'))
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled')
      actual: extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled')
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/opensearch/domain-error-logging/policy.yaml
    md5Hash: 06F4E5B330718F697C36168C013E5F96
    content: "---\nnames:\n  full: \"AWS OpenSearch Domain error logging is not enabled\"\
      \n  contextual: \"Domain error logging is not enabled\"\ndescription: >\n  Ensure\
      \ that error logging is enabled for Amazon OpenSearch Service domains. \n  Error\
      \ logs are useful for troubleshooting and provide information about \n  issues\
      \ encountered by the domain.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n  -\
      \ \"SECURITY\"\nframeworkMappings:\n  - \"/frameworks/cloudaware/logging-and-monitoring/logging-and-monitoring-configuration\"\
      \n  - \"/frameworks/aws-fsbp-v1.0.0/es/04\"\n  - \"/frameworks/aws-fsbp-v1.0.0/opensearch/04\"\
      \nsimilarPolicies:\n  awsSecurityHub:\n    - name: \"[Opensearch.4] OpenSearch\
      \ domain error logging to CloudWatch Logs should be enabled\"\n      url: \"\
      https://docs.aws.amazon.com/securityhub/latest/userguide/opensearch-controls.html#opensearch-4\"\
      \n    - name: \"[ES.4] Elasticsearch domain error logging to CloudWatch Logs\
      \ should be enabled\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/es-controls.html#es-4\"\
      \n"
  - path: /ce/ca/aws/opensearch/domain-error-logging/prod.logic.yaml
    md5Hash: 0A5D9186EFCC0B713CB5030815BA5054
    content: "---\ninputType: \"CA10__CaAwsElasticsearchDomain__c\"\ntestData:\n \
      \ - file: \"test-data.json\"\nimportExtracts:\n  - file: \"/types/CA10__CaAwsElasticsearchDomain__c/object.extracts.yaml\"\
      \nconditions:\n  - status: \"INCOMPLIANT\"\n    currentStateMessage: \"Log publishing\
      \ options are not configured.\"\n    remediationMessage: \"Enable error logging\
      \ (ES_APPLICATION_LOGS) for the OpenSearch domain.\"\n    check:\n      IS_EMPTY:\n\
      \        arg:\n          EXTRACT: \"CA10__logPublishingOptionsJson__c\"    \n\
      \  - status: \"INCOMPLIANT\"\n    currentStateMessage: \"Error logging (ES_APPLICATION_LOGS)\
      \ is explicitly disabled in the configuration.\"\n    remediationMessage: \"\
      Enable error logging (ES_APPLICATION_LOGS) for the OpenSearch domain.\"\n  \
      \  check:\n      NOT:\n        arg:\n          JSON_QUERY_BOOLEAN:\n       \
      \     arg:\n              EXTRACT: \"caJsonFrom__logPublishingOptionsJson__c\"\
      \n            expression: \"ES_APPLICATION_LOGS.enabled\"\n            undeterminedIf:\n\
      \              evaluationError: \"The ES_APPLICATION_LOGS key is missing from\
      \ the configuration.\"\n              resultTypeMismatch: \"The logging status\
      \ value is not a boolean.\"\n  - status: \"COMPLIANT\"\n    currentStateMessage:\
      \ \"Error logging (ES_APPLICATION_LOGS) is enabled.\"\n    check:\n      JSON_QUERY_BOOLEAN:\n\
      \        arg:\n          EXTRACT: \"caJsonFrom__logPublishingOptionsJson__c\"\
      \n        expression: \"ES_APPLICATION_LOGS.enabled\"\n        undeterminedIf:\n\
      \          evaluationError: \"The ES_APPLICATION_LOGS key is missing from the\
      \ configuration.\"\n          resultTypeMismatch: \"The logging status value\
      \ is not a boolean.\"\notherwise:\n  status: \"UNDETERMINED\"\n  currentStateMessage:\
      \ \"Unexpected values in the field.\""
  - path: /ce/ca/aws/opensearch/domain-error-logging/test-data.json
    md5Hash: FD66C20387D26D0E2B38CB7FB9F78E66
    content: |-
      [
          {
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "conditionIndex": 99,
                  "status": "DISAPPEARED"
              },
              "context": {
                  "snapshotTime": "2025-12-23T10:29:21Z"
              },
              "Id": "test1",
              "CA10__disappearanceTime__c": "2025-08-17T07:38:43Z",
              "CA10__logPublishingOptionsJson__c": "{\"SEARCH_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true},\"ES_APPLICATION_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true},\"INDEX_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true}}"
          },
          {
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('CA10__logPublishingOptionsJson__c').isEmpty()",
                  "conditionIndex": 199,
                  "status": "INCOMPLIANT"
              },
              "context": {
                  "snapshotTime": "2025-12-23T10:29:21Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__logPublishingOptionsJson__c": ""
          },
          {
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "not(extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled'))",
                  "conditionIndex": 299,
                  "status": "INCOMPLIANT"
              },
              "context": {
                  "snapshotTime": "2025-12-23T10:29:21Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__logPublishingOptionsJson__c": "{\"INDEX_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true}}"
          },
          {
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled')",
                  "conditionIndex": 399,
                  "status": "COMPLIANT"
              },
              "context": {
                  "snapshotTime": "2025-12-23T10:29:21Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__logPublishingOptionsJson__c": "{\"SEARCH_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true},\"ES_APPLICATION_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true},\"INDEX_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true}}"
          }
      ]
  - path: /types/CA10__CaAwsElasticsearchDomain__c/object.extracts.yaml
    md5Hash: 0D5B1BE6E92CCF38D456A62B74D84E17
    content: |
      ---
      extracts:
      # Values: true | false (TEXT). Not nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__serviceSoftwareUpdateAvailable__c"
          value:
            FIELD:
              path: "CA10__serviceSoftwareUpdateAvailable__c"
      # Checkbox
        - name: "CA10__encryptionAtRestEnabled__c"
          value:
            FIELD:
              path: "CA10__encryptionAtRestEnabled__c"
      # Nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__endpoint__c"
          value:
            FIELD:
              path: "CA10__endpoint__c"
      # Nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__vpcEndpoints__c"
          value:
            FIELD:
              path: "CA10__vpcEndpoints__c"
      # Checkbox
        - name: "CA10__nodeToNodeEncryptionEnabled__c"
          value:
            FIELD:
              path: "CA10__nodeToNodeEncryptionEnabled__c"
      # Nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__logPublishingOptionsJson__c"
          value:
            FIELD:
              returnType: "BYTES"
              path: "CA10__logPublishingOptionsJson__c"
        - name: "caJsonFrom__logPublishingOptionsJson__c"
          value:
            JSON_FROM:
              arg:
                EXTRACT: "CA10__logPublishingOptionsJson__c"
              undeterminedIf:
                isInvalid: "Log Publishing Options JSON is invalid."
      # Not nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__clusterConfigInstanceCount__c"
          value:
            FIELD:
              path: "CA10__clusterConfigInstanceCount__c"
      # Not nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__clusterConfigZoneAwarenessEnabled__c"
          value:
            FIELD:
              path: "CA10__clusterConfigZoneAwarenessEnabled__c"
      # Nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__clusterConfigDedicatedMasterEnabled__c"
          value:
            FIELD:
              path: "CA10__clusterConfigDedicatedMasterEnabled__c"
      # Nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__clusterConfigDedicatedMasterCount__c"
          value:
            FIELD:
              path: "CA10__clusterConfigDedicatedMasterCount__c"
      # Nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__endpointOptionsEnforceHttps__c"
          value:
            FIELD:
              path: "CA10__endpointOptionsEnforceHttps__c"
      # Nullable. Can't have no access retrieved via es:DescribeDomains
        - name: "CA10__endpointOptionsTlsSecurityPolicy__c"
          value:
            FIELD:
              path: "CA10__endpointOptionsTlsSecurityPolicy__c"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "test1",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "conditionIndex" : 99,
      "status" : "DISAPPEARED"
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('CA10__logPublishingOptionsJson__c').isEmpty()",
      "conditionIndex" : 199,
      "status" : "INCOMPLIANT"
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "not(extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled'))",
      "conditionIndex" : 299,
      "status" : "INCOMPLIANT"
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled')",
      "conditionIndex" : 399,
      "status" : "COMPLIANT"
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsElasticsearchDomain__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__logPublishingOptionsJson__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-12-23T10:29:21Z")
    },
    "CA10__disappearanceTime__c" : new Date("2025-08-17T07:38:43Z"),
    "CA10__logPublishingOptionsJson__c" : "{\"SEARCH_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true},\"ES_APPLICATION_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true},\"INDEX_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true}}",
    "Id" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-23T10:29:21Z")
    },
    "CA10__logPublishingOptionsJson__c" : "",
    "Id" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-23T10:29:21Z")
    },
    "CA10__logPublishingOptionsJson__c" : "{\"INDEX_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true}}",
    "Id" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-23T10:29:21Z")
    },
    "CA10__logPublishingOptionsJson__c" : "{\"SEARCH_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true},\"ES_APPLICATION_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true},\"INDEX_SLOW_LOGS\":{\"cloudWatchLogsLogGroupArn\":\"cloudWatchLogsLogGroupArn\",\"enabled\":true}}",
    "Id" : "test4"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsElasticsearchDomain__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__logPublishingOptionsJson__c STRING,
          Id STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  OPTIONS (library=['gs://compliance-platform-public/jmespath.min.js'])
  AS r"""
  var TextLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
      };
      this.isEmpty = function(arg) {
          return this.normalize(arg) == '';
      };
      this.isNotEmpty = function(arg) {
          return this.normalize(arg) != '';
      };
      this.equal = function(left, right) {
          return this.normalize(left) == this.normalize(right);
      };
      this.notEqual = function(left, right) {
          return this.normalize(left) != this.normalize(right);
      };
      this.startsWith = function(arg, substring) {
          return this.normalize(arg).startsWith(this.normalize(substring));
      };
      this.endsWith = function(arg, substring) {
          return this.normalize(arg).endsWith(this.normalize(substring));
      };
      this.contains = function(arg, substring) {
          return this.normalize(arg).includes(this.normalize(substring));
      };
      this.containsAll = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
      };
      this.containsAny = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
      };
  }();
  var BytesLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg;
      };
      this.isEmpty = function(arg) {
          return this.normalize(arg) == '';
      };
      this.isNotEmpty = function(arg) {
          return this.normalize(arg) != '';
      };
      this.equal = function(left, right) {
          return this.normalize(left) == this.normalize(right);
      };
      this.notEqual = function(left, right) {
          return this.normalize(left) != this.normalize(right);
      };
      this.startsWith = function(arg, substring) {
          return this.normalize(arg).startsWith(this.normalize(substring));
      };
      this.endsWith = function(arg, substring) {
          return this.normalize(arg).endsWith(this.normalize(substring));
      };
      this.contains = function(arg, substring) {
          return this.normalize(arg).includes(this.normalize(substring));
      };
      this.containsAll = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
      };
      this.containsAny = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
      };
  }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function extract3() { if (!this.out) { this.out = obj.CA10__logPublishingOptionsJson__c; } return this.out; };
      references1.push('Log Publishing Options JSON [obj.CA10__logPublishingOptionsJson__c]: ' + obj.CA10__logPublishingOptionsJson__c);
      if (BytesLib.isEmpty(extract3.call(extract3))) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__logPublishingOptionsJson__c').isEmpty()", currentStateMessage: "Log publishing options are not configured.", currentStateReferences: references1.join('\n'), remediation: "Enable error logging (ES_APPLICATION_LOGS) for the OpenSearch domain.", runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function jsonQueryChecked5() {
          var input = extract7.call(extract7);
          var out;
          try {
              out = jmespath.search(input, 'ES_APPLICATION_LOGS.enabled');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled').isResultTypeMismatch()", currentStateMessage: "The logging status value is not a boolean.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled').isEvaluationFailed()", currentStateMessage: "The ES_APPLICATION_LOGS key is missing from the configuration.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked8() {
          var input = extract10.call(extract10);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extract('CA10__logPublishingOptionsJson__c').asJson().isInvalid()", currentStateMessage: "Log Publishing Options JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function extract10() { if (!this.out) { this.out = obj.CA10__logPublishingOptionsJson__c; } return this.out; };
      function extract7() { if (!this.out) { this.out = jsonChecked8(); } return this.out; };
      try {
          if (!jsonQueryChecked5()) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "not(extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled'))", currentStateMessage: "Error logging (ES_APPLICATION_LOGS) is explicitly disabled in the configuration.", currentStateReferences: references1.join('\n'), remediation: "Enable error logging (ES_APPLICATION_LOGS) for the OpenSearch domain.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function jsonQueryChecked12() {
          var input = extract14.call(extract14);
          var out;
          try {
              out = jmespath.search(input, 'ES_APPLICATION_LOGS.enabled');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled').isResultTypeMismatch()", currentStateMessage: "The logging status value is not a boolean.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:303", {cause: {status: 'UNDETERMINED', conditionIndex: 303, conditionText: "extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled').isEvaluationFailed()", currentStateMessage: "The ES_APPLICATION_LOGS key is missing from the configuration.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked15() {
          var input = extract17.call(extract17);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "extract('CA10__logPublishingOptionsJson__c').asJson().isInvalid()", currentStateMessage: "Log Publishing Options JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function extract17() { if (!this.out) { this.out = obj.CA10__logPublishingOptionsJson__c; } return this.out; };
      function extract14() { if (!this.out) { this.out = jsonChecked15(); } return this.out; };
      try {
          if (jsonQueryChecked12()) {
              return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('caJsonFrom__logPublishingOptionsJson__c').jsonQueryText('ES_APPLICATION_LOGS.enabled')", currentStateMessage: "Error logging (ES_APPLICATION_LOGS) is enabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Unexpected values in the field.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;


  SELECT
    expectedResult.Id as Id,
    IF (
      IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '')
      AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1)
      AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '')
      AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''),
      "MATCH",
      "FAIL"
    ) as match,
    expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus,
    expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex,
    expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText,
    expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError
  FROM UNNEST(mock_ExpectedResult()) expectedResult
  LEFT JOIN (
      SELECT
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__logPublishingOptionsJson__c AS CA10__logPublishingOptionsJson__c,
          sObject.Id AS Id,
          process_CA10__CaAwsElasticsearchDomain__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__logPublishingOptionsJson__c AS CA10__logPublishingOptionsJson__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsElasticsearchDomain__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
