-
Notifications
You must be signed in to change notification settings - Fork 10
feat(project): Add superuser settings endpoint #1129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
57bff1a
03a36b3
e979224
ec3c006
4089f68
4caeb76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| Update settings for a project by ID. | ||
|
|
||
| Patches the `settings` JSONB of the project identified by the path `project_id`. Only the | ||
| keys provided in the request body are changed; existing keys are kept. | ||
|
|
||
| **Settings** | ||
|
|
||
| - `tracing` (bool): enable/disable Langfuse tracing for this project. Off by default to | ||
| conserve the org's Langfuse rate-limit/credit budget. Gates tracing for both the | ||
| response path and evaluations; when off, evaluations fall back to cosine-only scoring. | ||
|
|
||
| **Scope:** superusers may patch any project across organizations. A project-scoped key may | ||
| patch only its own bound project; targeting any other `project_id` returns 403. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,4 +32,6 @@ All paths relative to `backend/app/`. | |
| missing required fields are rejected at the request boundary (422). | ||
| - `ProjectPublic.settings` is `dict[str, JsonValue]` — free-form JSONB whose | ||
| writable keys are defined by `ProjectSettingsUpdate` (`PATCH | ||
| /projects/settings`), currently just `tracing`. | ||
| /projects/settings` for the key's own project; `PATCH | ||
| /projects/{project_id}/settings` for superusers targeting any project), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Document project-scoped access for the ID route.
🤖 Prompt for AI Agents |
||
| currently just `tracing`. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🌐 Web query:
For FastAPI 0.116.0, does a required Pydantic request-body parameter return HTTP 422 before the route handler runs when a PATCH request has no body?💡 Result:
Yes, in FastAPI 0.116.0, if a route handler defines a required Pydantic request-body parameter, FastAPI will return an HTTP 422 Unprocessable Entity error before the route handler is executed if the request is missing a body [1][2][3]. FastAPI performs request validation—including parsing and validating the request body against the Pydantic model—as part of the request lifecycle before the handler function is called [3][4]. Because a Pydantic model parameter in a route signature is considered required by default, the framework expects a corresponding JSON payload [2][5][6]. If no body is provided, the validation layer detects the missing data and raises a RequestValidationError, which FastAPI automatically converts into an HTTP 422 response [1][2][4]. To avoid this 422 error when a body is optional, you must explicitly make the parameter optional in the route handler signature by assigning it a default value, typically None [2][5]: async def update_item(item: MyModel | None = None):... Note that while this allows the route handler to run without a body, the Pydantic model itself should generally have all fields set as optional (e.g., with
= None) if the intention is to support partial updates via PATCH [7][1][2].Citations:
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-backend
Length of output: 24814
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-backend
Length of output: 7274
Return 400 when the HTTP body is absent.
settings_in: ProjectSettingsUpdateis required, so FastAPI returns 422 before the handler runs. Make it optional, rejectNone, and add a test that callsclient.patch(...)withoutjson.🤖 Prompt for AI Agents