Skip to content

Add error responses to ML Delete API documentation#11957

Open
kolchfa-aws wants to merge 2 commits intomainfrom
fix-issue-7838-ml-delete-api-exceptions
Open

Add error responses to ML Delete API documentation#11957
kolchfa-aws wants to merge 2 commits intomainfrom
fix-issue-7838-ml-delete-api-exceptions

Conversation

@kolchfa-aws
Copy link
Collaborator

Closes #7838

Checklist

  • By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and subject to the Developers Certificate of Origin.
    For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>
@github-actions
Copy link

Thank you for submitting your PR. The PR states are In progress (or Draft) -> Tech review -> Doc review -> Merged.

Before you submit your PR for doc review, make sure the content is technically accurate. If you need help finding a tech reviewer, tag a maintainer.

When you're ready for doc review, tag the assignee of this PR. The doc reviewer may push edits to the PR directly or leave comments and editorial suggestions for you to address (let us know in a comment if you have a preference).

@kolchfa-aws
Copy link
Collaborator Author

@b4sjoo Could you review this PR?

@kolchfa-aws kolchfa-aws added Tech review PR: Tech review in progress backport 3.5 labels Feb 25, 2026
@kolchfa-aws
Copy link
Collaborator Author

@ylwu-amzn Could you review this PR?


## Error responses

If you attempt to delete a memory container that doesn't exist, the API behavior may vary. Ensure that the memory container exists before attempting to delete it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may vary is vague . @b4sjoo, can you share what will exactly happen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the code, there is a 500 error path and 404 error path. The 404 error path only occurs if the container passes the initial retrieval check but then fails during the actual deletion operation, which is less common. I think a 404 should be returned in both cases. Let me open an issue in the ml-commons repo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the ml-commons issue opensearch-project/ml-commons#4706

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right this is a bug. 404 is expected output here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Should I document the current behavior or can we put in the fix for this soon in the ml-commons repo? @ylwu-amzn Please let me know.


## Error responses

If you attempt to delete a context management configuration that doesn't exist, the behavior depends on your OpenSearch version and configuration. The API may return an error indicating the resource was not found.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The API may return an error" — so what else might it do? Developers are left guessing:

Return a 404?

@mingshl , can you help ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it throw exception, but it's 500 error. I will raise an issue to make it 404 error.

DELETE /_plugins/_ml/context_management/sliding_window_max_40000_tokens_managers123
{
  "error": {
    "root_cause": [
      {
        "type": "runtime_exception",
        "reason": "Context management template not found: sliding_window_max_40000_tokens_managers123"
      }
    ],
    "type": "runtime_exception",
    "reason": "Context management template not found: sliding_window_max_40000_tokens_managers123"
  },
  "status": 500
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the new response is here, @kolchfa-aws you can use it for the doc

DELETE /_plugins/_ml/context_management/sliding_window_max_40000_tokens_managers123 will be:                                         
                                                                                                                                                               
  {                                                                                                                                                            
    "error": {                                                                                                                                                 
      "root_cause": [                                                                                                                                          
        {
          "type": "status_exception",
          "reason": "Context management template not found: sliding_window_max_40000_tokens_managers123"
        }
      ],
      "type": "status_exception",
      "reason": "Context management template not found: sliding_window_max_40000_tokens_managers123"
    },
    "status": 404
  }```

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @mingshl! Added this response.

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 3.5 Tech review PR: Tech review in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DOC] Update delete API in ML

4 participants