Skip to content

fix: require projectUrl for classify_st_url endpoint#44

Open
vee1e wants to merge 1 commit into
chaoss:mainfrom
vee1e:fix/url-endpoint-empty-predictions
Open

fix: require projectUrl for classify_st_url endpoint#44
vee1e wants to merge 1 commit into
chaoss:mainfrom
vee1e:fix/url-endpoint-empty-predictions

Conversation

@vee1e
Copy link
Copy Markdown
Contributor

@vee1e vee1e commented May 5, 2026

Summary

The /api/classify_st_url endpoint was returning HTTP 200 with an empty predictions array when no projectUrl was provided, which is confusing to API consumers.

Before (Issue)

When making a request without a projectUrl:

Request:

POST /api/classify_st_url
Content-Type: application/json

{
  "projectName": "Test Project",
  "projectDescription": "A test description"
}

Response (HTTP 200 OK):

{
  "projectName": "Test Project",
  "projectUrl": null,
  "predictions": []
}

Problems:

  • HTTP 200 suggests success, but no predictions were made
  • Empty predictions array with no explanation why
  • API consumers might think this is a bug
  • No clear indication that URL is required for URL-based classification

After (Fixed)

Same request now returns:

Response (HTTP 400 Bad Request):

{
  "error": "Project URL is required for URL-based classification"
}

Benefits:

  • Clear error message tells user exactly what is needed
  • HTTP 400 indicates client error (missing required field)
  • No confusing empty predictions array
  • Aligns with endpoint name (URL-based classification)

Changes Made

In backend/app.py, the classify_st_url function:

  • Changed from conditional if/else block to early validation
  • Removed the else branch that returned a message-only response
  • Now returns 400 Bad Request immediately when projectUrl is missing
  • Simplified control flow and removed dead code

The fix is minimal and focused on improving API usability through proper error handling.

Previously, when no URL was provided to /api/classify_st_url, the endpoint
returned HTTP 200 with an empty predictions array, which was confusing to
API consumers.

Now returns 400 Bad Request with a clear error message:
'Project URL is required for URL-based classification'

This aligns with the endpoint name (URL-based classification) and provides
immediate feedback when a required parameter is missing.

Signed-off-by: vee1e <vermalucky2004@gmail.com>
@vee1e vee1e force-pushed the fix/url-endpoint-empty-predictions branch from 217fc1b to 02f0b3c Compare May 5, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant