linmengmeng-1314 opened a new issue, #330:
URL: https://github.com/apache/hugegraph-ai/issues/330

   ### Description
   
   The `POST /config/graph` endpoint always returns **500 Internal Server 
Error** when called, due to an attribute name mismatch between the request 
model and the API handler.
   
   ### Environment
   
   - Version: `hugegraph/rag:1.7.0` (Docker image)
   - Component: `hugegraph-llm`
   
   ### Steps to Reproduce
   
   1. Start the RAG service with `hugegraph/rag:1.7.0`
   2. Call the `/config/graph` endpoint:
      ```bash
      curl -X POST http://localhost:8001/config/graph \
        -H "Content-Type: application/json" \
        -d '{"url": "127.0.0.1:8080", "graph": "hugegraph"}'
      ```
   3. Observe 500 error
   
   ### Error Log
   
   ```
   AttributeError: 'GraphConfigRequest' object has no attribute 'name'
     File "hugegraph_llm/api/rag_api.py", line 158, in graph_config_api
       res = apply_graph_conf(req.url, req.name, req.user, req.pwd, req.gs, 
origin_call="http")
   ```
   
   ### Root Cause
   
   In `rag_api.py:158`, the handler uses `req.name`, but the 
`GraphConfigRequest` model (`rag_requests.py`) defines the field as `graph`, 
not `name`:
   
   ```python
   class GraphConfigRequest(BaseModel):
       url: str = Query("127.0.0.1:8080", description="hugegraph client url.")
       graph: str = Query("hugegraph", description="hugegraph client name.")  # 
<-- field is "graph"
       user: str = Query("", description="hugegraph client user.")
       pwd: str = Query("", description="hugegraph client pwd.")
       gs: str = None
   ```
   
   ### Fix
   
   In `hugegraph-llm/src/hugegraph_llm/api/rag_api.py`, line 158:
   
   ```python
   # Before
   res = apply_graph_conf(req.url, req.name, req.user, req.pwd, req.gs, 
origin_call="http")
   
   # After
   res = apply_graph_conf(req.url, req.graph, req.user, req.pwd, req.gs, 
origin_call="http")
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to