diff --git a/backend/main.py b/backend/main.py index 2de27111d..f3d8371b0 100644 --- a/backend/main.py +++ b/backend/main.py @@ -477,6 +477,7 @@ async def get_pipeline_valves(pipeline_id: str, user=Depends(get_admin_user)): if pipeline_id in app.state.MODELS and "pipeline" in app.state.MODELS[pipeline_id]: pipeline = app.state.MODELS[pipeline_id] + r = None try: urlIdx = pipeline["urlIdx"] @@ -495,12 +496,23 @@ async def get_pipeline_valves(pipeline_id: str, user=Depends(get_admin_user)): # Handle connection error here print(f"Connection error: {e}") + detail = "Pipeline not found" + + if r is not None: + try: + res = r.json() + if "detail" in res: + detail = res["detail"] + except: + pass + raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, - detail="Pipeline not found", + status_code=( + r.status_code if r is not None else status.HTTP_404_NOT_FOUND + ), + detail=detail, ) - return {"data": pipeline["pipeline"]["valves"]} else: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, @@ -514,6 +526,7 @@ async def get_pipeline_valves_spec(pipeline_id: str, user=Depends(get_admin_user if pipeline_id in app.state.MODELS and "pipeline" in app.state.MODELS[pipeline_id]: pipeline = app.state.MODELS[pipeline_id] + r = None try: urlIdx = pipeline["urlIdx"] @@ -532,12 +545,21 @@ async def get_pipeline_valves_spec(pipeline_id: str, user=Depends(get_admin_user # Handle connection error here print(f"Connection error: {e}") - raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, - detail="Pipeline not found", - ) + detail = "Pipeline not found" + if r is not None: + try: + res = r.json() + if "detail" in res: + detail = res["detail"] + except: + pass - return {"data": pipeline["pipeline"]["valves"]} + raise HTTPException( + status_code=( + r.status_code if r is not None else status.HTTP_404_NOT_FOUND + ), + detail=detail, + ) else: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, @@ -554,6 +576,7 @@ async def update_pipeline_valves( if pipeline_id in app.state.MODELS and "pipeline" in app.state.MODELS[pipeline_id]: pipeline = app.state.MODELS[pipeline_id] + r = None try: urlIdx = pipeline["urlIdx"] @@ -576,9 +599,21 @@ async def update_pipeline_valves( # Handle connection error here print(f"Connection error: {e}") + detail = "Pipeline not found" + + if r is not None: + try: + res = r.json() + if "detail" in res: + detail = res["detail"] + except: + pass + raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, - detail="Pipeline not found", + status_code=( + r.status_code if r is not None else status.HTTP_404_NOT_FOUND + ), + detail=detail, ) else: raise HTTPException( diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index 9850581f9..ffa5c6bbb 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -156,7 +156,12 @@ export const updatePipelineValves = async ( }) .catch((err) => { console.log(err); - error = err; + + if ('detail' in err) { + error = err.detail; + } else { + error = err; + } return null; }); diff --git a/src/lib/components/admin/Settings/Pipelines.svelte b/src/lib/components/admin/Settings/Pipelines.svelte index 3680e3621..dda33d055 100644 --- a/src/lib/components/admin/Settings/Pipelines.svelte +++ b/src/lib/components/admin/Settings/Pipelines.svelte @@ -1,43 +1,63 @@