qfa.domain.errors#
Domain error hierarchy for the feedback analysis backend.
Exceptions
Non-recoverable error during feedback analysis. |
|
Raised when an analysis exceeds the allowed deadline. |
|
Raised when an API request cannot be authenticated. |
|
Raised when a user lacks permission for the requested operation. |
|
Base error for all domain-level exceptions. |
|
|
Raised when estimated tokens for the submitted feedback exceed the limit. |
Raised when we try to create a key with an existing id. |
|
Raised when we try to access a key that doesn't exist. |
|
|
Raised when the LLM provider returns a 400 Bad Request response. |
|
Raised when the LLM provider rejects the request due to content policy. |
|
Base error for LLM adapter failures. |
|
Raised when the LLM provider returns a rate-limit response. |
|
Raised when a structured LLM response fails schema validation. |
|
Raised when the LLM provider does not respond in time. |
Raised when an LLM call is recorded without an active CallContext. |
|
Raised when input matches a known prompt-injection pattern. |
|
Raised when an operation requires superuser privileges but the tenant does not allow superusers. |
|
Raised when we try to access a tenant that doesn't exist. |
|
Raised when a usage-repository read fails due to backend unavailability. |
- exception qfa.domain.errors.DomainError[source]#
Bases:
ExceptionBase error for all domain-level exceptions.
- exception qfa.domain.errors.AnalysisError[source]#
Bases:
DomainErrorNon-recoverable error during feedback analysis.
- exception qfa.domain.errors.AnalysisTimeoutError[source]#
Bases:
AnalysisErrorRaised when an analysis exceeds the allowed deadline.
- exception qfa.domain.errors.PromptInjectionDetectedError[source]#
Bases:
AnalysisErrorRaised when input matches a known prompt-injection pattern.
Sole raiser:
LiteLLMClient._check_injection.
- exception qfa.domain.errors.FeedbackTooLargeError(message: str, *, estimated_tokens: int, limit: int)[source]#
Bases:
AnalysisErrorRaised when estimated tokens for the submitted feedback exceed the limit.
- exception qfa.domain.errors.LLMError(message: str, *, provider_status: int | None = None)[source]#
Bases:
DomainErrorBase error for LLM adapter failures.
provider_statusis a classified scalar (the provider’s HTTP status code), never free text — see ADR-018.Nonemeans the provider did not expose a usable status code.
- exception qfa.domain.errors.LLMTimeoutError(message: str, *, provider_status: int | None = None)[source]#
Bases:
LLMErrorRaised when the LLM provider does not respond in time.
- exception qfa.domain.errors.LLMBadRequestError(message: str, *, provider_status: int | None = None)[source]#
Bases:
LLMErrorRaised when the LLM provider returns a 400 Bad Request response.
- exception qfa.domain.errors.LLMContentPolicyViolationError(message: str, *, provider_status: int | None = None, category: str | None = None, severity: str | None = None, discarded_prompt_tokens: int = 0, discarded_completion_tokens: int = 0, discarded_cost: float = 0.0)[source]#
Bases:
LLMBadRequestErrorRaised when the LLM provider rejects the request due to content policy.
categoryandseverityare Azure’s content-filter annotation (e.g."violence"/"high") when the rejection was detected from a completed response’scontent_filter_resultsrather than sniffed from aBadRequestErrormessage — a closed, low-cardinality set of classified scalars, never free text (see ADR-018). Both areNonewhen unavailable.discarded_prompt_tokens,discarded_completion_tokensanddiscarded_costcarry usage billed by the provider on retried attempts that were discarded because the response was blocked — Azure’s asynchronous filter generates (and bills) a completion before rejecting it. They are the cumulative total across every discarded attempt for this call, so a caller recording usage from this exception still accounts for the real spend even though noLLMResponsewas ever returned. Zero when the rejection carried no billable usage (e.g. the synchronous, pre-generation rejection path).
- exception qfa.domain.errors.LLMRateLimitError(message: str, *, provider_status: int | None = None, retry_after: int | None = None)[source]#
Bases:
LLMErrorRaised when the LLM provider returns a rate-limit response.
retry_afteris the provider’sRetry-Aftervalue in seconds.Nonemeans the provider gave no usable header.
- exception qfa.domain.errors.LLMResponseParseError(message: str, *, provider_status: int | None = None)[source]#
Bases:
LLMErrorRaised when a structured LLM response fails schema validation.
Distinct from other
LLMErrorcases (timeouts, missing content, provider failures) so callers may choose to treat malformed model output as an empty/absent result instead of failing the request.
- exception qfa.domain.errors.AuthenticationError[source]#
Bases:
DomainErrorRaised when an API request cannot be authenticated.
- exception qfa.domain.errors.AuthorizationError[source]#
Bases:
DomainErrorRaised when a user lacks permission for the requested operation.
- exception qfa.domain.errors.TenantDoesNotAllowSuperUsersError[source]#
Bases:
DomainErrorRaised when an operation requires superuser privileges but the tenant does not allow superusers.
- exception qfa.domain.errors.KeyAlreadyExistsError[source]#
Bases:
DomainErrorRaised when we try to create a key with an existing id.
- exception qfa.domain.errors.KeyNotFoundError[source]#
Bases:
DomainErrorRaised when we try to access a key that doesn’t exist.
- exception qfa.domain.errors.TenantNotFoundError[source]#
Bases:
DomainErrorRaised when we try to access a tenant that doesn’t exist.
- exception qfa.domain.errors.MissingCallScopeError[source]#
Bases:
RuntimeErrorRaised when an LLM call is recorded without an active CallContext.
Indicates a wiring bug: the driving adapter forgot to enter a
call_scopeblock before calling the LLM. Should never reach a user.
Bases:
DomainErrorRaised when a usage-repository read fails due to backend unavailability.
This signals that the repository is wired and the request hit the DB but the connection or query failed transiently (e.g. Postgres unreachable, pool exhausted, broker reset). The API surfaces this as
503 {"code": "usage_backend_unavailable"}.