fix(gateway): eliminate silent error swallowing in CHIT API - #650
Merged
POWERFULMOVES merged 5 commits intoFeb 17, 2026
Merged
Conversation
…rors The bare `except: pass` in decrypt_anchor() caught all exceptions (including SystemExit) and then unconditionally popped anchor_enc, permanently losing the encrypted anchor with no trace. Now catches only json.JSONDecodeError and UnicodeDecodeError, logs the error with constellation ID, and returns early to preserve anchor_enc for retry/debugging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ingest_cgp() swallowed all exceptions from emit_event() including ImportError, ConnectionRefused, and serialization errors. Downstream consumers (Discord publisher, monitoring) would silently stop receiving geometry events with no indication in logs. Now: ImportError logs at DEBUG (expected when events module absent), all other exceptions log full traceback via logger.exception. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The endpoint discarded ingest_cgp()'s return value, giving callers only
{"ok": true} with no reference to track the ingested shape. Now returns
shape_id and event type so callers (mcp_server, external agents) can
perform subsequent operations (jumps, decode) without recomputing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
_learned_enhance() silently fell back to keyword-frequency summarizer when CHIT_T5_MODEL was configured but failed (CUDA OOM, corrupt model, network error). Operators received degraded results with no indication. Now: ImportError logs WARNING (expected when transformers not installed), other exceptions log full traceback before falling back. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Incorporate both aead.decrypt InvalidTag guard (base branch) and improved JSON decode error logging (PR #650). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
POWERFULMOVES
merged commit Feb 17, 2026
6b9dc73
into
PMOVES.AI-Edition-Hardened
6 of 7 checks passed
POWERFULMOVES
pushed a commit
that referenced
this pull request
Mar 26, 2026
#650) * feat: Provider-agnostic error handling for Issue #362 Implements generic error handling that works for OpenAI, Google AI, Anthropic, and other LLM providers to prevent silent failures. Essential files only: 1. Provider error adapters (new) - handles any LLM provider 2. Backend API key validation - detects invalid keys before operations 3. Frontend error handler - provider-aware error messages 4. Updated hooks - uses generic error handling Core functionality: ✅ Validates API keys before expensive operations (crawl, upload, refresh) ✅ Shows clear provider-specific error messages ✅ Works with OpenAI: 'Please verify your OpenAI API key in Settings' ✅ Works with Google: 'Please verify your Google API key in Settings' ✅ Prevents 90-minute debugging sessions from Issue #362 No unnecessary changes - only essential error handling logic. Fixes #362 * fix: Enhance API key validation with detailed logging and error handling - Add comprehensive logging to trace validation flow - Ensure validation actually blocks operations on authentication failures - Improve error detection to catch wrapped OpenAI errors - Fail fast on any validation errors to prevent wasted operations This should ensure invalid API keys are caught before crawl starts, not during embedding processing after documents are crawled. * fix: Simplify API key validation to always fail on exceptions - Remove complex provider adapter imports that cause module issues - Simplified validation that fails fast on any embedding creation error - Enhanced logging to trace exactly what's happening - Always block operations when API key validation fails This ensures invalid API keys are caught immediately before crawl operations start, preventing silent failures. * fix: Add API key validation to refresh and upload endpoints The validation was only added to new crawl endpoint but missing from: - Knowledge item refresh endpoint (/knowledge-items/{source_id}/refresh) - Document upload endpoint (/documents/upload) Now all three endpoints that create embeddings will validate API keys before starting operations, preventing silent failures on refresh/upload. * security: Implement core security fixes from CodeRabbit review Enhanced sanitization and provider detection based on CodeRabbit feedback: ✅ Comprehensive regex patterns for all provider API keys - OpenAI: sk-[a-zA-Z0-9]{48} with case-insensitive matching - Google AI: AIza[a-zA-Z0-9_-]{35} with flexible matching - Anthropic: sk-ant-[a-zA-Z0-9_-]{10,} with variable length ✅ Enhanced provider detection with multiple patterns - Case-insensitive keyword matching (openai, google, anthropic) - Regex-based API key detection for reliable identification - Additional keywords (gpt, claude, vertex, googleapis) ✅ Improved sanitization patterns - Provider-specific URL sanitization (openai.com, googleapis.com, anthropic.com) - Organization and project ID redaction - OAuth token and bearer token sanitization - Sensitive keyword detection and generic fallback ✅ Sanitized error logging - All error messages sanitized before logging - Prevents sensitive data exposure in backend logs - Maintains debugging capability with redacted information Core security improvements while maintaining simplicity for beta deployment. * fix: Replace ad-hoc error sanitization with centralized ProviderErrorFactory - Remove local _sanitize_provider_error implementation with inline regex patterns - Add ProviderErrorFactory import from embeddings.provider_error_adapters - Update _validate_provider_api_key calls to pass correct active embedding provider - Replace sanitization call with ProviderErrorFactory.sanitize_provider_error() - Eliminate duplicate logic and fixed-length key assumptions - Ensure provider-specific, configurable sanitization patterns are used consistently 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: Remove accidentally committed PRP file 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: address code review feedback - Add barrel export for providerErrorHandler in utils/index.ts - Change TypeScript typing from 'any' to 'unknown' for strict type safety --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Rasmus Widing <rasmus.widing@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Four atomic commits eliminating bare
except: passblocks and silent data loss in the CHIT gateway API:fix(chit): preserve anchor_enc on decryption failure — bare
except: passcaught everything (including SystemExit), then unconditionally poppedanchor_enc, permanently losing encrypted data. Now catches onlyJSONDecodeError/UnicodeDecodeError, logs error, preservesanchor_encfor retry.fix(chit): log event emission failures —
emit_event()failures swallowed silently, causing downstream consumers (Discord publisher, monitoring) to stop receiving geometry events. Now logs ImportError at DEBUG, other errors vialogger.exception.fix(chit): return shape_id from /geometry/event — endpoint discarded
ingest_cgp()return value. Callers now receive{ok, shape_id, event}for tracking.fix(chit): log transformer summarization failures —
_learned_enhance()silently fell back to keyword summarizer when configured T5 model failed. Now logs the failure before fallback.Fixes silent failure audit issues #3 (HIGH), #4 (HIGH), #6 (MEDIUM), #7 (MEDIUM).
Test plan
🤖 Generated with Claude Code