mirror of
https://github.com/AJaySi/ALwrity.git
synced 2026-04-26 01:15:52 +03:00
[PR #375] [MERGED] Harden usage-limit middleware failure handling #677
Labels
No labels
AI Content Agents
AI Content Strategy
AI Content planning
AI Marketing Tools
AI SEO
AI personalization
AI writer
ALwrity Copi-lot
Alwrity web search
Anthropic
DeepSeek
Gemini AI
Integration
LLM
OnBoarding
OnBoarding
RAG knowledgebase Memory
bug
documentation
enhancement
good first issue
help wanted
invalid
openai
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ALwrity#677
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/AJaySi/ALwrity/pull/375
Author: @AJaySi
Created: 3/4/2026
Status: ✅ Merged
Merged: 3/5/2026
Merged by: @AJaySi
Base:
main← Head:codex/update-error-handling-in-monitoring-middleware📝 Commits (1)
d82569aHarden usage limit enforcement failure handling📊 Changes
1 file changed (+117 additions, -7 deletions)
View changed files
📝
backend/services/subscription/monitoring_middleware.py(+117 -7)📄 Description
Motivation
Description
USAGE_LIMITS_EMERGENCY_FAIL_OPENwith helper_is_usage_limits_emergency_fail_open_enabled()to allow explicit temporary fail-open behavior._record_usage_limit_enforcement_error()that bindsevent=usage_limit_enforcement_errorand maintains lightweight in-process counters inUSAGE_LIMIT_ENFORCEMENT_ERROR_METRICS._build_usage_enforcement_unavailable_response()which returns a standard503payload (USAGE_LIMIT_ENFORCEMENT_UNAVAILABLE) and updatedcheck_usage_limits_middlewareto: return503when DB/session/tables/operational/unexpected errors prevent enforcement for protected (provider-detected) routes unless the emergency fail-open flag is enabled, and to continue returning429for explicit limit violations.osand initialized the new constants and helpers inbackend/services/subscription/monitoring_middleware.py.Testing
python -m py_compile backend/services/subscription/monitoring_middleware.pyto validate the module compiles successfully (succeeded).Codex Task
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.