Skip to content

Commit

Permalink
feat: change return error code
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanFM committed Dec 17, 2024
1 parent 59f832a commit db8f98b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions jina/serve/runtimes/gateway/http_fastapi_app_docarrayv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_fastapi_app(
if expose_graphql_endpoint:
logger.error(f' GraphQL endpoint is not enabled when using docarray >0.30')
with ImportExtensions(required=True):
from fastapi import FastAPI, Response, HTTPException
from fastapi import FastAPI, Response, HTTPException, status as http_status
from fastapi.middleware.cors import CORSMiddleware
import pydantic
from pydantic import Field
Expand Down Expand Up @@ -216,7 +216,7 @@ async def post(body: input_model, response: Response):
status = resp.header.status

if status.code == jina_pb2.StatusProto.ERROR:
raise HTTPException(status_code=499, detail=status.description)
raise HTTPException(status_code=http_status.HTTP_500_INTERNAL_SERVER_ERROR, detail=status.description)
else:
result_dict = resp.to_dict()
return result_dict
Expand Down
4 changes: 2 additions & 2 deletions jina/serve/runtimes/worker/http_csp_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_fastapi_app(
"""
with ImportExtensions(required=True):
import pydantic
from fastapi import FastAPI, HTTPException, Request
from fastapi import FastAPI, HTTPException, Request, status as http_status
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel, Field
from pydantic.config import BaseConfig, inherit_config
Expand Down Expand Up @@ -131,7 +131,7 @@ async def process(body) -> output_model:
status = resp.header.status

if status.code == jina_pb2.StatusProto.ERROR:
raise HTTPException(status_code=499, detail=status.description)
raise HTTPException(status_code=http_status.HTTP_500_INTERNAL_SERVER_ERROR, detail=status.description)
else:
return output_model(data=resp.docs, parameters=resp.parameters)

Expand Down
4 changes: 2 additions & 2 deletions jina/serve/runtimes/worker/http_fastapi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_fastapi_app(
:return: fastapi app
"""
with ImportExtensions(required=True):
from fastapi import FastAPI, Response, HTTPException
from fastapi import FastAPI, Response, HTTPException, status as http_status
import pydantic
from fastapi.middleware.cors import CORSMiddleware
import os
Expand Down Expand Up @@ -116,7 +116,7 @@ async def post(body: input_model, response: Response):
status = resp.header.status

if status.code == jina_pb2.StatusProto.ERROR:
raise HTTPException(status_code=499, detail=status.description)
raise HTTPException(status_code=http_status.HTTP_500_INTERNAL_SERVER_ERROR, detail=status.description)
else:
if not docarray_v2:
docs_response = resp.docs.to_dict()
Expand Down
3 changes: 1 addition & 2 deletions jina/serve/runtimes/worker/request_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,6 @@ def _extract_tracing_context(
) -> Optional['Context']:
if self.tracer:
from opentelemetry.propagate import extract

context = extract(dict(metadata))
return context

Expand Down Expand Up @@ -1116,7 +1115,7 @@ async def process_data(

if is_generator:
result = await self.handle_generator(
requests=requests,tracing_context=tracing_context
requests=requests, tracing_context=tracing_context
)
else:
result = await self.handle(
Expand Down

0 comments on commit db8f98b

Please sign in to comment.