Bug Summary
The queryBuilder controller in apps/dashboard-api/src/controllers/ai.controller.js validates that prompt is a non-empty string, but applies no upper-bound constraint on its length:
const safePrompt = prompt.trim();
if (!safeCollectionName || !safePrompt) {
throw new AppError(400, "Collection name and prompt are required");
}
// safePrompt is forwarded to the Python AI service with no length cap
const result = await forwardToPythonService('/query-builder', {
prompt: safePrompt,
schema: schemaFields,
...
});
An authenticated developer can submit a prompt containing hundreds of thousands of characters. This payload is forwarded directly to the underlying LLM service via forwardToPythonService. Each token in the prompt consumes quota from the project's or platform's AI allocation. A single oversized prompt can exhaust a plan's monthly AI credits in one request.
Steps to Reproduce
- Log in as a developer with any plan.
- POST to
/api/projects/:id/ai/query-builder with { "collectionName": "items", "prompt": "<100,000 character string>" }.
- Observe the full prompt is forwarded to the AI service and the response returns successfully.
Expected Behavior
safePrompt should be capped at a practical maximum length (for example, 2000 characters). Requests exceeding the limit should be rejected with HTTP 400 before any AI service call is made.
Actual Behavior
Prompts of arbitrary length are accepted and forwarded to the AI service, consuming unbounded token quota per request.
Affected File
apps/dashboard-api/src/controllers/ai.controller.js, queryBuilder function.
@geturbackend I would like to work on this issue. Could you please assign/ it to me? Contributing under NSoC '26.
Bug Summary
The
queryBuildercontroller inapps/dashboard-api/src/controllers/ai.controller.jsvalidates thatpromptis a non-empty string, but applies no upper-bound constraint on its length:An authenticated developer can submit a prompt containing hundreds of thousands of characters. This payload is forwarded directly to the underlying LLM service via
forwardToPythonService. Each token in the prompt consumes quota from the project's or platform's AI allocation. A single oversized prompt can exhaust a plan's monthly AI credits in one request.Steps to Reproduce
/api/projects/:id/ai/query-builderwith{ "collectionName": "items", "prompt": "<100,000 character string>" }.Expected Behavior
safePromptshould be capped at a practical maximum length (for example, 2000 characters). Requests exceeding the limit should be rejected with HTTP 400 before any AI service call is made.Actual Behavior
Prompts of arbitrary length are accepted and forwarded to the AI service, consuming unbounded token quota per request.
Affected File
apps/dashboard-api/src/controllers/ai.controller.js,queryBuilderfunction.@geturbackend I would like to work on this issue. Could you please assign/ it to me? Contributing under NSoC '26.