

# Troubleshoot structured data grounding

This topic lists problems that you might encounter when you ground AWS Glue Data Catalog tables in an ontology. For each problem, it gives the cause and what to do. For the tasks, see [Start grounding by associating an ontology](ontology-grounding-start.md), [Review and edit grounding proposals](ontology-grounding-review.md), and [Turn grounding off and on](ontology-grounding-turn-off.md).

## ValidationException: mapping a custom ontology to a catalog connection
<a name="ontology-grounding-troubleshoot-mapping"></a>

The connection mapping fails with a `ValidationException`. This happens when you map a custom ontology on an AWS Glue Data Catalog connection. A connection mapping accepts a custom ontology only on an Amazon Bedrock Managed Knowledge Base connection. On an AWS Glue Data Catalog connection, the mapping uses the built-in Data ontology.

To ground your tables in a custom ontology, associate the ontology with the Agent Context instead. For more information, see [Start grounding by associating an ontology](ontology-grounding-start.md).

## FAILED: the association task doesn’t import an ontology
<a name="ontology-grounding-troubleshoot-associate"></a>

 `GetTask` returns the status `FAILED` for the association task. At least one ontology wasn’t imported. The task might have imported the other ontologies. The `statusMessage` has the form "Imported *<n>* of *<m>* ontologies. Failed: *<details>*", where *<details>* names each ontology that failed and why. On the console, the task’s run status in the **Customization tasks** table shows that it failed.

 `statusReasonCode` gives the reason for the first ontology that failed. The following list describes each code and what to do:
+  `ONTOLOGY_INVALID` – The ontology is missing, it has no source that AWS Context can load, or its source isn’t valid. Check the ontology’s ID and status. If its source isn’t valid, upload a corrected source as a new ontology. Then start a new task.
+  `ONTOLOGY_ALREADY_IMPORTED` – The ontology is already loaded in the Agent Context. Grounding already ran, or is running, for it. You can’t associate it again. To make grounding check every table again, associate a different published ontology, for example an edited copy that you upload as a new ontology. For more information, see [Bring your own ontology](ontology-byo.md).
+  `GRAPH_NOT_ACTIVE` – The Agent Context isn’t available. For example, it was deleted after the task started. Check the Agent Context’s status with `GetAgentContext`.
+  `ONTOLOGY_IMPORT_UNAVAILABLE` – The import didn’t complete for a temporary reason. Start a new task.

If `statusReasonCode` is missing, AWS Context couldn’t run the import. The `statusMessage` says what to do, such as to contact AWS Support.

To start a new task for only the ontologies that failed, list only those ontologies in `ontologies`. For the request fields, see [`StartTask` request fields for associating an ontology](ontology-grounding-start.md#ontology-grounding-start-reference).

 `StartTask` itself can fail before a task starts. If it fails with a `ValidationException`, check the request against [`StartTask` request fields for associating an ontology](ontology-grounding-start.md#ontology-grounding-start-reference). If you reused a client token with different parameters, the `ValidationException` says so: send a new client token.

## ValidationException: approving a held import fails
<a name="ontology-grounding-troubleshoot-approve-association"></a>

 `AcceptCurationProposal` fails with a `ValidationException` that gives the reason. This can happen when a curation policy held an ontology import for review. The proposal and its change set end with status `FAILED`. When you approve the proposal, AWS Context loads the ontology. The load can’t succeed when the ontology was deleted, its source can’t be read or is too large, or a newer load of the ontology replaced this one.

To try again, start a new association task. If you deleted the ontology, or AWS Context can’t load its source, upload a corrected source as a new ontology, and then associate that ontology. For more information, see [Bring your own ontology](ontology-byo.md) and [Associate an ontology with the API](ontology-grounding-start.md#ontology-grounding-start-api).

## No grounding proposals appear
<a name="ontology-grounding-troubleshoot-none"></a>

The curation queue shows no proposals that **Ontology grounding** generated. This happens when a condition that grounding needs isn’t met, so grounding can’t run.

To find and fix the cause, do the following:

1. Make sure that the association task imported the ontology, and that a curation policy doesn’t still hold the import for review. A task with the status `FAILED` might not have imported it. For more information, see [Start grounding by associating an ontology](ontology-grounding-start.md) and [FAILED: the association task doesn’t import an ontology](#ontology-grounding-troubleshoot-associate).

1. Make sure that your tables appear in the Agent Context.

1. Make sure that entity resolution is `ENABLED` for the Agent Context. For more information, see [Turn grounding off and on](ontology-grounding-turn-off.md).

1. Make sure that the ontology is a custom ontology, not a built-in ontology. For more information, see [Prerequisites for structured data grounding](ontology-grounding-prerequisites.md).

1. Make sure that the curation queue isn’t full of proposals that wait for review. If it is, approve or reject some of them. If the queue stayed full for 24 hours, grounding stopped checking the remaining tables. For more information, see [How structured data grounding works](ontology-grounding-how-it-works.md).

## ConflictException: you can’t approve or reject a proposal
<a name="ontology-grounding-troubleshoot-decide"></a>

 `AcceptCurationProposal` or `RejectCurationProposal` fails with a `ConflictException`. This happens in the following cases:
+ The proposal changed after you read it, so your `revisionId` is out of date. For example, someone dropped links from it.
+ The proposal no longer waits for review. For example, someone already approved or rejected it, or its auto-reject window ended.

Call `GetCurationProposal` to read the proposal’s current status and `revisionId`. If the status is still `PENDING_REVIEW`, approve or reject it again with the new `revisionId`. For the request fields, see [`AcceptCurationProposal` and `RejectCurationProposal` request fields](ontology-grounding-review.md#ontology-grounding-review-reference).

If you reuse a client token from a request for another proposal, the call fails with a `ValidationException` instead. Send a new client token.

## You can’t drop links from a proposal
<a name="ontology-grounding-troubleshoot-edit"></a>

If AWS Context can’t drop the links, `UpdateChangeSet` fails, and the change set doesn’t change. The following list describes each exception and what to do:
+  `ValidationException` – The request breaks a rule for editing a grounding proposal. For example, you can’t drop a table’s link to a class without dropping its column links in the same request. Each entry in `operationsToRemove` must match exactly one current operation. Check the request against [Rules for editing a grounding proposal](ontology-grounding-review.md#ontology-grounding-review-rules). You also get this exception when you reuse a client token for another change set or a different request. Send a new client token.
+  `ConflictException` – The `changeSetVersion` that you sent isn’t the latest, or the proposal no longer waits for review. Another request might also have changed the proposal at the same time. Call `GetChangeSet` again, and then try again with the latest `changeSetVersion`. For the request fields, see [`UpdateChangeSet` request fields](ontology-grounding-review.md#ontology-grounding-review-update-reference).

After an edit, a `nextToken` from an earlier `ListChangeSetOperations` response fails with a `ValidationException`. Call `ListChangeSetOperations` again without a `nextToken`.

## Next steps
<a name="ontology-grounding-next"></a>

After you ground your tables, you can do the following:
+ Link your grounded tables with content from your knowledge base connections. For more information, see [Structured to unstructured linking through schema types](linking-structured-to-unstructured.md).
+ Remove an ontology that you no longer use from your Agent Contexts, or delete it. For more information, see [Removing and deleting ontologies](ontology-retire-delete.md).