Skip to content

Conversation

@heheda12345
Copy link
Collaborator

@heheda12345 heheda12345 commented Aug 15, 2025

Purpose

Let the user to see more errors from chat completion API

Test Plan

Run a request that will raise error

Test Result

without this pr, client will see

raise self._make_status_error_from_response(err.response) from None
openai.InternalServerError: Error code: 500

with this pr, client will see

    raise self._make_status_error_from_response(err.response) from None
openai.InternalServerError: Error code: 500 - {'error': {'message': 'Tool call in Chat Completion API is not supported for gpt-oss yet. Please use Responses API instead.', 'type': 'Internal Server Error', 'param': None, 'code': 500}}

(Optional) Documentation Update


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Signed-off-by: Chen Zhang <zhangch99@outlook.com>
@heheda12345 heheda12345 requested a review from aarnphm as a code owner August 15, 2025 03:55
@mergify mergify bot added the frontend label Aug 15, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves error logging for chat completions by catching exceptions and returning them in the HTTP response, which is a good improvement for client-side debugging. I've suggested a refinement to handle NotImplementedError specifically, which will provide more accurate HTTP status codes to the client and improve consistency with other API endpoints in the file.

Comment on lines +670 to +674
try:
generator = await handler.create_chat_completion(request, raw_request)
except Exception as e:
raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR.value,
detail=str(e)) from e
Copy link
Contributor

Choose a reason for hiding this comment

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

high

While adding a general exception handler is a good step to improve error reporting, it would be more precise to handle specific exceptions like NotImplementedError with a more appropriate HTTP status code. This would align with REST best practices and improve consistency with other endpoints in this file, such as /tokenize, which returns a 501 Not Implemented status for this error. This provides clearer feedback to the client about why the request failed.

    try:
        generator = await handler.create_chat_completion(request, raw_request)
    except NotImplementedError as e:
        raise HTTPException(status_code=HTTPStatus.NOT_IMPLEMENTED.value,
                            detail=str(e)) from e
    except Exception as e:
        raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR.value,
                            detail=str(e)) from e

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

try:
generator = await handler.create_chat_completion(request, raw_request)
except Exception as e:
raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR.value,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a breakdown of status codes instead of mapping everything to HTTP code 500.

The 5xx error codes also indicate that the error is server-blame (i.e. bug in server code) which isn't always the case (e.g. the request itself may have other issues).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think if request has any issue, we expect the engine to return an error response without raising an exception. But happy to add if you can list some simple ones.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. So generator is always expected to return the next message which may include the error response, instead of raising any exception? If that's the case, then yeah, code 500 would be appropriate here.

Signed-off-by: Chen Zhang <zhangch99@outlook.com>
@bbartels
Copy link
Contributor

My only concern is that this may log prompts/responses, so in sensitive deployments with --disable-log-requests where user prompts shall not be logged this could accidentally expose some information

@heheda12345
Copy link
Collaborator Author

What does "sensitive deployment" mean? Sensitive to speed or not give sensitive output to users? I thought --disable-log-requests is for cases that are sensitive to speed as it doesn't change the response on client side.

@heheda12345
Copy link
Collaborator Author

merge with main branch to include the entrypoint CI failure fix from main branch

@bbartels
Copy link
Contributor

I meant where prompts contain sensitive data that should not be logged. We administrate such deployments at work where shouldn't be able to know what our customers are prompting

@heheda12345
Copy link
Collaborator Author

This PR doesn't add new logs to server side. The error information is at client side.

@heheda12345 heheda12345 added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 19, 2025
@simon-mo simon-mo merged commit b95697d into vllm-project:main Aug 20, 2025
44 of 46 checks passed
djmmoss pushed a commit to djmmoss/vllm that referenced this pull request Aug 21, 2025
Signed-off-by: Chen Zhang <zhangch99@outlook.com>
Signed-off-by: Duncan Moss <djm.moss@gmail.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: Chen Zhang <zhangch99@outlook.com>
xiao-llm pushed a commit to xiao-llm/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: Chen Zhang <zhangch99@outlook.com>
Signed-off-by: Xiao Yu <xiao.yu@amd.com>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: Chen Zhang <zhangch99@outlook.com>
mengxingkongzhouhan pushed a commit to mengxingkongzhouhan/vllm that referenced this pull request Aug 30, 2025
Signed-off-by: Chen Zhang <zhangch99@outlook.com>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Sep 3, 2025
Signed-off-by: Chen Zhang <zhangch99@outlook.com>
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
Signed-off-by: Chen Zhang <zhangch99@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants