fix: address PR #68 review — silent failures, path traversal, dead code#69
fix: address PR #68 review — silent failures, path traversal, dead code#69chitcommit wants to merge 1 commit intomainfrom
Conversation
Critical: - Encode user-supplied caseId in evidence API URLs (path traversal risk) - Surface contradiction fetch failures in Evidence page (was silent empty) - Show error state on transaction fetch failure in Accounts (was silent empty) - Show dispute load error in LitigationAssistant picker (was empty catch) Important: - Remove dead actionIcon/Icon code from Recommendations - Remove unused RefreshCw import from Accounts - Guard useEffect pre-population to run once (prevents overwriting user edits) - Restore console.error logging in Recommendations act/dismiss - Clear stale data when loading new case in Evidence - Surface timeline.partial warning in Evidence page - Show retry on history load failure in ActionQueue - Clear error state on reload in Legal page - Surface missing dispute from URL param in LitigationAssistant 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. |
|
📝 WalkthroughWalkthroughThe PR introduces consistent error state tracking across multiple page components for API failures (transactions, decision history, contradictions, disputes). Additionally, the API layer now URL-encodes Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
To use Codex here, create a Codex account and connect to github. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ui/src/pages/LitigationAssistant.tsx`:
- Around line 67-76: The code sets selectedDisputeId before verifying the
dispute exists, which can leave an invalid ID in state; update the logic in the
block that reads disputeId/disputes so you first find the dispute via
disputes.find(dd => dd.id === disputeId) and only then call
setSelectedDisputeId(disputeId) and mark prePopulated.current = true; if the
dispute is found, also setRecipient(d.counterparty) and setRawNotes(...) as you
already do, otherwise leave selectedDisputeId unchanged and show the toast.error
(toast.error(...) remains in the else branch); ensure prePopulated.current is
only set when the dispute exists to avoid signaling a successful pre-population
for an invalid ID.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c310ab0e-4695-440a-95a8-0e86cf8534c4
📒 Files selected for processing (7)
ui/src/lib/api.tsui/src/pages/Accounts.tsxui/src/pages/ActionQueue.tsxui/src/pages/Evidence.tsxui/src/pages/Legal.tsxui/src/pages/LitigationAssistant.tsxui/src/pages/Recommendations.tsx
| if (disputeId && disputes.length > 0) { | ||
| prePopulated.current = true; | ||
| setSelectedDisputeId(disputeId); | ||
| const d = disputes.find(dd => dd.id === disputeId); | ||
| if (d) { | ||
| if (d.counterparty) setRecipient(d.counterparty); | ||
| if (d.description) setRawNotes(prev => prev || d.description || ''); | ||
| } else { | ||
| toast.error('Dispute not found', `Linked dispute ${disputeId.slice(0, 8)}... was not found`); | ||
| } |
There was a problem hiding this comment.
Avoid preselecting an invalid dispute ID from URL.
selectedDisputeId is set before confirming the dispute exists. That can leave an invalid ID in state and allow follow-up actions to target a nonexistent dispute.
💡 Suggested fix
- if (disputeId && disputes.length > 0) {
+ if (disputeId && disputes.length > 0) {
prePopulated.current = true;
- setSelectedDisputeId(disputeId);
const d = disputes.find(dd => dd.id === disputeId);
if (d) {
+ setSelectedDisputeId(disputeId);
if (d.counterparty) setRecipient(d.counterparty);
if (d.description) setRawNotes(prev => prev || d.description || '');
} else {
+ setSelectedDisputeId('');
toast.error('Dispute not found', `Linked dispute ${disputeId.slice(0, 8)}... was not found`);
}
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ui/src/pages/LitigationAssistant.tsx` around lines 67 - 76, The code sets
selectedDisputeId before verifying the dispute exists, which can leave an
invalid ID in state; update the logic in the block that reads disputeId/disputes
so you first find the dispute via disputes.find(dd => dd.id === disputeId) and
only then call setSelectedDisputeId(disputeId) and mark prePopulated.current =
true; if the dispute is found, also setRecipient(d.counterparty) and
setRawNotes(...) as you already do, otherwise leave selectedDisputeId unchanged
and show the toast.error (toast.error(...) remains in the else branch); ensure
prePopulated.current is only set when the dispute exists to avoid signaling a
successful pre-population for an invalid ID.
Summary
Addresses 10 findings from comprehensive PR review of #68 (8 outcome-driven UI flows):
Critical (4):
encodeURIComponenton user-suppliedcaseIdin evidence API URLs — prevents path traversal.catch(() => {}))Important (6):
actionIcon/Iconcode + unusedRefreshCwimportuseEffectpre-population to run once only (prevents overwriting user edits on re-render)console.errorlogging in Recommendations act/dismisstimeline.partialwarning banner in Evidence pageTest plan
?dispute=ID— should show toast errortsc --noEmit+vite buildpass🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Style