Troubleshoot deleting an ontology
This topic lists problems that you might encounter when you remove an ontology from Agent Contexts or delete it. For each problem, it gives the cause and what to do. Most deletions fail because a connection mapping still uses the ontology, a recent change conflicts with the deletion, or you don’t have access to the ontology. For the tasks, see Remove an ontology from Agent Contexts and Delete an ontology.
You can’t remove or replace the ontology in an Agent Context
If UpdateAgentContext fails, the Agent Context doesn’t change. The following list describes each exception and what to do:
-
ValidationException– The replacement ontology isn’t published. Or you named a custom ontology on a connection that isn’t an Amazon Bedrock Managed Knowledge Base connection. Publish the ontology, or use a built-in ontology on that connection. For the rules, see UpdateAgentContext request fields.You also get this exception when the ontology is too large to map to a knowledge base connection. The message is "Ontology <id> cannot be mapped to a Knowledge Base connection: <reason>." Use a smaller ontology, or use it for grounding instead. For more information, see Start grounding by associating an ontology.
-
ConflictException– The Agent Context isn’tACTIVE, another request changed it at the same time, or a connection in the list isn’tACTIVE. Wait until the Agent Context and the connection areACTIVE, callGetAgentContextagain, and then try again.You also get this exception when you keep or re-add a connection whose earlier removal from this Agent Context is still deleting its data. Wait until the deletion finishes, and then try again.
-
ResourceNotFoundException– A connection or ontology that you named doesn’t exist. TheresourceTypeandresourceIdvalues in the exception name it. Check the ID or ARN. -
AccessDeniedException– The replacement ontology belongs to another account. Use an ontology from your account or a built-in ontology.
For the steps to remove or replace the ontology, see Find and remove the ontology with the API.
ConflictException: an Agent Context uses the ontology
DeleteOntology fails with a ConflictException, and AWS Context deletes nothing. The exception lists the Agent Context IDs in resourceId. The exception sets resourceType to agent-context, or omits it. This happens when an Agent Context still maps the ontology and isn’t DELETING.
Remove the ontology from each listed Agent Context, or delete the ones that are FAILED, and then try again. If an Agent Context is CREATING or UPDATING, wait until it’s ACTIVE or FAILED first. For more information, see Remove an ontology from Agent Contexts.
If you just removed the ontology from an Agent Context, the exception can still list that Agent Context for up to 5 minutes. Wait 5 minutes after the update that removed the ontology, and then try again.
ConflictException: a recent change blocks the deletion
DeleteOntology fails with a ConflictException whose resourceType is ontology, and AWS Context deletes nothing. This happens in the following cases:
-
An Agent Context that maps the ontology, or mapped it until you removed it, was created or updated in the last 5 minutes.
-
The ontology’s status, induction, or draft changed while the deletion ran.
If you created or updated such an Agent Context in the last 5 minutes, including the update that removed the ontology, wait 5 minutes after that create or update, and then try again. In the other cases, try again. For the prerequisites for a deletion, see Delete an ontology.
AccessDeniedException: you don’t have access to delete the ontology
DeleteOntology fails with an AccessDeniedException. This happens in the following cases:
-
You specify the ARN of a built-in ontology.
-
You specify the ARN of another account’s ontology.
-
You don’t have permission for the
context:DeleteOntologyaction on the ontology.
You can delete only ontologies that your account owns. Check the ID and your permissions. For more information, see DeleteOntology request fields.
ResourceNotFoundException: the ontology isn’t found
DeleteOntology fails with a ResourceNotFoundException. This happens when no ontology with this ID has existed in your account. A built-in ontology’s ID also returns this exception, because an ID always names an ontology in your own account. An ontology that you already deleted doesn’t cause this exception. Check the ID with ListOntologies. For the ontologyId rules, see DeleteOntology request fields.
InternalServerException: the deletion doesn’t finish
DeleteOntology fails with an InternalServerException. This happens when AWS Context deleted the ontology but didn’t remove all of its stored files. To finish the cleanup, call DeleteOntology again with the same ID. Because the call is idempotent, the retry succeeds and removes the remaining files. For more information, see Delete an ontology with the API.