You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
The API returns HTTP 429 correctly but doesn't include the standard Retry-After header. Many clients automatically respect this header when implementing retries.
Recommendation:
Return Retry-After with the remaining TTL.
Redis Initialization Should Be Explicitly Guarded
File: finbot/core/ratelimit/limiter.py
Problem:
The implementation assumes event_bus.redis is initialized. If Redis initialization fails during startup or is unavailable in certain test environments, every request will raise an AttributeError, which is then caught by the generic exception handler. Although the fail-open behavior works, it results in unnecessary exception logging on every request.
Negative TTL Values Can Produce Confusing Responses
File: finbot/core/ratelimit/limiter.py
Problem:
Redis may return -1 or -2 for TTL. Using these values directly could generate messages such as:
Thanks for the review! I've addressed all three issues in commit 9e334e1:
Retry-After header — added headers={"Retry-After": str(ttl)} to the HTTPException so clients automatically know when to retry.
Redis guard — replaced direct event_bus.redis access with getattr(event_bus, "redis", None) and an explicit None check, eliminating AttributeError logging when Redis is unavailable.
Negative TTL — added a guard for ttl < 0 (Redis returns -1 for no expiry, -2 for missing key) that falls back to window_seconds, preventing confusing negative values in the response message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Challenge Library Expansion
Adds 6 new CTF challenges covering ASI-03 (Identity and Impersonation)
and ASI-05 (Indirect Prompt Injection).
ASI-03 Challenges (3)
ASI-05 Challenges (3)
Each challenge includes
Tests added (Week 3-4)
tests/unit/ctf/detectors/