Skip to content

Add rate limiting to knowledge upload endpoint #76

@sre-helmcode

Description

@sre-helmcode

Context

The knowledge base upload endpoint (POST /api/knowledge/documents) processes files asynchronously (parse → chunk → embed → store). Each upload triggers CPU-intensive work (embedding via Ollama). Without rate limiting, a client could overwhelm the system with rapid uploads.

Required Change

Add rate limiting middleware to the upload endpoint. Options:

  • Fiber rate limiter middleware (fiber/middleware/limiter)
  • Per-org rate limit (e.g., 10 uploads per minute)
  • Or global rate limit as a simpler first step

Security Context

Identified during security audit of the RAG feature (MED-2). Resource exhaustion vector — each upload triggers a processing goroutine with Ollama embedding calls.

Acceptance Criteria

  • Rate limiting configured on POST /api/knowledge/documents
  • Returns 429 Too Many Requests when limit exceeded
  • Rate limit is reasonable (suggested: 10 uploads/min per org)

Metadata

Metadata

Assignees

Labels

backendBackend relatedenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions