Skip to content

Creating Kendra WEBCRAWLERV2 data source via API fails with weird message

0

I'm trying to create Kendra index data sources using the "TEMPLATE" data type with "WEBCRAWLERV2" as the data source type using the AWS SDK for Ruby v3: https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Kendra/Client.html#create_data_source-instance_method

I'm following this guide in "Connection Instructions > API" section: https://docs.aws.amazon.com/kendra/latest/dg/data-source-v2-web-crawler.html

And I'm using this schema for the "template_configuration" for the data source: https://docs.aws.amazon.com/kendra/latest/dg/ds-schemas.html#ds-schema-web-crawler

When I check my template configuration against the Amazon Kendra Web Crawler JSON Schema using a JSON Schema Validator tool, it passes validation correctly.

My request body (sanitized, as a Ruby hash) is as follows:

{:type=>"TEMPLATE",
   :configuration=>
    {:template_configuration=>
      {:template=>
        {:type=>"WEBCRAWLERV2",
         :connection_configuration=>
          {:repository_endpoint_metadata=>{:site_map_urls=>["https://www.example.com/sitemap.xml"], :authentication=>"NoAuthentication"}},
         :repository_configurations=>
          {:web_page=>
            {:field_mappings=>
              [{:data_source_field_name=>"sourceUrl", :index_field_name=>"_source_uri", :index_field_type=>"STRING"},
               {:data_source_field_name=>"title", :index_field_name=>"_document_title", :index_field_type=>"STRING"},
               {:data_source_field_name=>"category", :index_field_name=>"_category", :index_field_type=>"STRING"},
               {:data_source_field_name=>"author", :index_field_name=>"_authors", :index_field_type=>"STRING"},
               {:data_source_field_name=>"description", :index_field_name=>"description", :index_field_type=>"STRING"}]},
           :attachment=>
            {:field_mappings=>
              [{:data_source_field_name=>"sourceUrl", :index_field_name=>"_source_uri", :index_field_type=>"STRING"},
               {:data_source_field_name=>"category", :index_field_name=>"_category", :index_field_type=>"STRING"}]}},
         :sync_mode=>"FULL_CRAWL",
         :additional_properties=>
          {:rate_limit=>"300",
           :max_file_size=>"50",
           :crawl_depth=>"2",
           :crawl_sub_domain=>false,
           :crawl_all_domain=>false,
           :max_links_per_url=>"100",
           :honor_robots=>false,
           :crawl_attachments=>false,
           :inclusion_url_crawl_patterns=>[],
           :exclusion_url_crawl_patterns=>[],
           :inclusion_url_index_patterns=>[],
           :exclusion_url_index_patterns=>[]}}}},
   :role_arn=>"arn:aws:iam::1234567890:role/service-role/AmazonKendra-data-sources-role",
   :name=>"crawler-name",
   :index_id=>"my-kendra-index-id",
   :schedule=>"0 0 * * *",
   :client_token=>"a-generated-client-token"}

When I try the request, I get a ValidationException error with the error message:

Encountered 4 error(s) while processing the data source configuration input against the schema for data source type: WEBCRAWLERV2. (Aws::Kendra::Errors::ValidationException)\n#: required key  not found\n#: required key  not found\n#: required key  not found\n#: required key  not found\n

Which is four instances of required key not found; there is no key name, and two spaces where the key name should be, indicating that the key name didn't get printed correctly in the error message (it should be between the two spaces I imagine).

My questions:

  • Is this request body valid? If not, why not?
  • What are the four missing required keys?
  • Why didn't the key names evaluate in the error message?

Looking forward to guidance.

asked 2 years ago200 views

2 Answers
1

Based on the information provided, it appears that you're encountering an issue with the Kendra API when trying to create a WEBCRAWLERV2 data source. Let's address your questions:

  1. Is this request body valid? The request body you've provided seems to be structured correctly for the most part. However, the ValidationException suggests that there are some required keys missing.

  2. What are the four missing required keys? Unfortunately, the error message you're receiving is not providing specific information about which keys are missing. This appears to be a bug in the error reporting, as the key names are not being properly displayed in the error message.

  3. Why didn't the key names evaluate in the error message? This seems to be an issue with how the error is being generated or formatted by the AWS Kendra service. It's not a problem with your code, but rather with how the service is reporting the error.

Given that your template configuration passes validation against the JSON schema, the issue might be related to how the AWS SDK for Ruby is processing or sending the request, or how Kendra is interpreting it.

To troubleshoot this issue, you could try the following:

  1. Double-check that all required fields for the WEBCRAWLERV2 data source type are present in your configuration.
  2. Ensure that the structure of your request matches exactly what's expected by the API, including any nested objects or arrays.
  3. Try creating the data source using a different method, such as the AWS CLI or another SDK, to see if the issue persists.
  4. If possible, start with a minimal configuration and gradually add more fields to identify which part of the configuration is causing the issue.

If the problem continues, it would be advisable to contact AWS support, as this appears to be an issue with how the Kendra service is handling or reporting errors. They may be able to provide more specific guidance or address the bug in their error reporting.
Sources
[Class: Aws::Kendra::Types::ValidationException

— AWS SDK for Ruby V3](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Kendra/Types/ValidationException.html)  

[Class: Aws::Kendra::Types::InvalidRequestException

— AWS SDK for Ruby V3](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Kendra/Types/InvalidRequestException.html)

answered 2 years ago

EXPERT

reviewed 2 years ago

0

There is a json schema on this page showing the required fields: https://docs.aws.amazon.com/kendra/latest/dg/ds-schemas.html#ds-confluence-schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "connectionConfiguration": {
      "type": "object",
      "properties": {
        "repositoryEndpointMetadata": {
          "type": "object",
          "properties": {
            "hostUrl": {
              "type": "string",
              "pattern": "https:.*"
            },
            "type": {
              "type": "string",
              "enum": [
                "SAAS",
                "ON_PREM"
              ]
            },
            "authType": {
              "type": "string",
              "enum": [
                "Basic",
                "OAuth2",
                "Personal-token"
              ]
            }
          },
          "required": [
            "hostUrl",
            "type",
            "authType"
          ]
        }
      },
      "required": [
        "repositoryEndpointMetadata"
      ]
    },
    "repositoryConfigurations": {
      "type": "object",
      "properties": {
        "space": {
          "type": "object",
          "properties": {
            "fieldMappings": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "indexFieldName": {
                      "type": "string"
                    },
                    "indexFieldType": {
                      "type": "string",
                      "enum": [
                        "STRING",
                        "STRING_LIST",
                        "DATE"
                      ]
                    },
                    "dataSourceFieldName": {
                      "type": "string"
                    },
                    "dateFieldFormat": {
                      "type": "string",
                      "pattern": "yyyy-MM-dd'T'HH:mm:ss'Z'"
                    }
                  },
                  "required": [
                    "indexFieldName",
                    "indexFieldType",
                    "dataSourceFieldName"
                  ]
                }
              ]
            }
          },
          "required": [
            "fieldMappings"
          ]
        },
        "page": {
          "type": "object",
          "properties": {
            "fieldMappings": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "indexFieldName": {
                      "type": "string"
                    },
                    "indexFieldType": {
                      "type": "string",
                      "enum": [
                        "STRING",
                        "STRING_LIST",
                        "DATE",
                        "LONG"
                      ]
                    },
                    "dataSourceFieldName": {
                      "type": "string"
                    },
                    "dateFieldFormat": {
                      "type": "string",
                      "pattern": "yyyy-MM-dd'T'HH:mm:ss'Z'"
                    }
                  },
                  "required": [
                    "indexFieldName",
                    "indexFieldType",
                    "dataSourceFieldName"
                  ]
                }
              ]
            }
          },
          "required": [
            "fieldMappings"
          ]
        },
        "blog": {
          "type": "object",
          "properties": {
            "fieldMappings": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "indexFieldName": {
                      "type": "string"
                    },
                    "indexFieldType": {
                      "type": "string",
                      "enum": [
                        "STRING",
                        "STRING_LIST",
                        "DATE",
                        "LONG"
                      ]
                    },
                    "dataSourceFieldName": {
                      "type": "string"
                    },
                    "dateFieldFormat": {
                      "type": "string",
                      "pattern": "yyyy-MM-dd'T'HH:mm:ss'Z'"
                    }
                  },
                  "required": [
                    "indexFieldName",
                    "indexFieldType",
                    "dataSourceFieldName"
                  ]
                }
              ]
            }
          },
          "required": [
            "fieldMappings"
          ]
        },
        "comment": {
          "type": "object",
          "properties": {
            "fieldMappings": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "indexFieldName": {
                      "type": "string"
                    },
                    "indexFieldType": {
                      "type": "string",
                      "enum": [
                        "STRING",
                        "STRING_LIST",
                        "DATE",
                        "LONG"
                      ]
                    },
                    "dataSourceFieldName": {
                      "type": "string"
                    },
                    "dateFieldFormat": {
                      "type": "string",
                      "pattern": "yyyy-MM-dd'T'HH:mm:ss'Z'"
                    }
                  },
                  "required": [
                    "indexFieldName",
                    "indexFieldType",
                    "dataSourceFieldName"
                  ]
                }
              ]
            }
          },
          "required": [
            "fieldMappings"
          ]
        },
        "attachment": {
          "type": "object",
          "properties": {
            "fieldMappings": {
              "type": "array",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "indexFieldName": {
                      "type": "string"
                    },
                    "indexFieldType": {
                      "type": "string",
                      "enum": [
                        "STRING",
                        "STRING_LIST",
                        "DATE",
                        "LONG"
                      ]
                    },
                    "dataSourceFieldName": {
                      "type": "string"
                    },
                    "dateFieldFormat": {
                      "type": "string",
                      "pattern": "yyyy-MM-dd'T'HH:mm:ss'Z'"
                    }
                  },
                  "required": [
                    "indexFieldName",
                    "indexFieldType",
                    "dataSourceFieldName"
                  ]
                }
              ]
            }
          },
          "required": [
            "fieldMappings"
          ]
        }
      }
    },
    "additionalProperties": {
      "type": "object",
      "properties": {
        "usersAclS3FilePath": {
          "type": "string"
        },
        "isCrawlAcl": {
          "type": "boolean"
        },
        "fieldForUserId": {
          "type": "string"
        },
        "inclusionSpaceKeyFilter": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "exclusionSpaceKeyFilter": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "pageTitleRegEX": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "blogTitleRegEX": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "commentTitleRegEX": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "attachmentTitleRegEX": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "isCrawlPersonalSpace": {
          "type": "boolean"
        },
        "isCrawlArchivedSpace": {
          "type": "boolean"
        },
        "isCrawlArchivedPage": {
          "type": "boolean"
        },
        "isCrawlPage": {
          "type": "boolean"
        },
        "isCrawlBlog": {
          "type": "boolean"
        },
        "isCrawlPageComment": {
          "type": "boolean"
        },
        "isCrawlPageAttachment": {
          "type": "boolean"
        },
        "isCrawlBlogComment": {
          "type": "boolean"
        },
        "isCrawlBlogAttachment": {
          "type": "boolean"
        },
        "maxFileSizeInMegaBytes":  {
          "type":"string"
        },
        "inclusionFileTypePatterns": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "exclusionFileTypePatterns": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "inclusionUrlPatterns": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "exclusionUrlPatterns": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "proxyHost": {
          "type": "string"
        },
        "proxyPort": {
          "type": "string"
        }
      },
      "required": []
    },
    "type": {
      "type": "string",
      "pattern": "CONFLUENCEV2"
    },
    "enableIdentityCrawler": {
      "type": "boolean"
    },
    "syncMode": {
      "type": "string",
      "enum": [
        "FULL_CRAWL",
        "FORCED_FULL_CRAWL"
      ]
    },
    "secretArn": {
      "type": "string",
      "minLength": 20,
      "maxLength": 2048
    }
  },
  "version": {
    "type": "string",
    "anyOf": [
      {
        "pattern": "1.0.0"
      }
    ]
  },
  "required": [
    "connectionConfiguration",
    "repositoryConfigurations",
    "syncMode",
    "additionalProperties",
    "secretArn",
    "type"
  ]
}

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.