Skip to content

GetProject endpoint returns 200 with HTML instead of 404 for non-existent projects #11458

@kevinkouketsu

Description

@kevinkouketsu

Bug: GET /api/v1/projects/{projectId} returns 200 with HTML instead of 404 for non-existent projects

Description

When making a GET request to /api/v1/projects/{projectId} with a non-existent project UUID, the endpoint inconsistently returns a 200 status code with the Langflow frontend HTML page instead of the expected 404 Not Found response.
I believe the same happens on the flow endpoint.

Expected Behavior

The endpoint should return:

  • 404 Not Found when the project UUID doesn't exist in the database
  • 200 OK with project JSON data only when the project exists

Actual Behavior

The endpoint returns:

  • 200 OK with the Langflow frontend HTML (<!doctype html>...) for non-existent projects
  • Sometimes correctly returns 404 (inconsistent behavior)

Steps to Reproduce

  1. Make a GET request to /api/v1/projects/{non-existent-uuid}
  2. Use a valid UUID format (e.g., e0fbd415-31f1-4528-b01e-2ef8b2445399)
  3. Observe the response returns 200 with HTML instead of 404

Example Request

curl -X GET
"http://localhost:7860/api/v1/projects/e0fbd415-31f1-4528-b01e-2ef8b2445399"
-H "accept: application/json"
-H "x-api-key: $API_KEY"

Actual Response

Status: 200 OK
Content-Type: text/html

<!doctype html>
<html lang="en">
  <head>
    <base href="/" />
    <meta charset="UTF-8" />
    ...
    <title>Langflow</title>
    ...

Technical Details

  • Endpoint Code Reference:
@router.get("/{project_id}", response_model=FolderWithPaginatedFlows | FolderReadWithFlows, status_code=200)
async def read_project(
    *,
    session: DbSession,
    project_id: UUID,
  • UUID validation works correctly (tested with Python's UUID library)
  • The issue appears to be a route fallback to the frontend SPA

Root Cause Analysis

The API request is likely falling through to the frontend router, which serves the Langflow HTML application for all unmatched routes. This suggests:

  1. The API endpoint might not be properly raising a 404 exception when the project is not found
  2. There could be route precedence issues between the API and frontend routes

Use Case

I need to reliably check if a project exists via the API before performing operations on it. The inconsistent 200/404 behavior makes this impossible to implement correctly.

Additional Enhancement Request

Consider adding a query parameter (e.g., ?exclude_flows=true) to the endpoint to retrieve only project metadata without flows data, which would be useful for existence checks and lightweight queries.

Environment

  • Langflow Version: langflowai/langflow:latest
  • Deployment: Docker

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestjiraThis issue has been logged in Jira for fix by the engineering team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions