feat: smartlink redirects directly to CRE when only one CRE is linked#938
Conversation
|
Warning Review limit reached
More reviews will be available in 8 minutes and 32 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe Changessmartlink Direct CRE Redirect
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
application/tests/web_main_test.py (1)
588-600:⚠️ Potential issue | 🟠 Major | ⚡ Quick winSwap the expected CRE IDs for CWE vs ASVS redirects.
The assertions are inverted relative to fixture setup: CWE is linked through
dcd(222-222) and ASVS throughdcb(333-333).Suggested fix
- self.assertEqual(location, "/cre/333-333") + self.assertEqual(location, "/cre/222-222") @@ - self.assertEqual(location, "/cre/222-222") + self.assertEqual(location, "/cre/333-333")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@application/tests/web_main_test.py` around lines 588 - 600, The expected CRE IDs in the redirect assertions are inverted based on the fixture setup. In the test method, swap the expected location values for the CWE and ASVS endpoint assertions: the CWE redirect (to /smartlink/standard/CWE/v0.1.2) should expect location /cre/222-222, and the ASVS redirect (to /smartlink/standard/ASVS/v0.1.2) should expect location /cre/333-333. Change the first self.assertEqual(location, "/cre/333-333") to expect /cre/222-222 and the second self.assertEqual(location, "/cre/222-222") to expect /cre/333-333.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@application/tests/web_main_test.py`:
- Around line 588-600: The expected CRE IDs in the redirect assertions are
inverted based on the fixture setup. In the test method, swap the expected
location values for the CWE and ASVS endpoint assertions: the CWE redirect (to
/smartlink/standard/CWE/v0.1.2) should expect location /cre/222-222, and the
ASVS redirect (to /smartlink/standard/ASVS/v0.1.2) should expect location
/cre/333-333. Change the first self.assertEqual(location, "/cre/333-333") to
expect /cre/222-222 and the second self.assertEqual(location, "/cre/222-222") to
expect /cre/333-333.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 3e704195-f081-455a-bede-56adb71ae701
📒 Files selected for processing (2)
application/tests/web_main_test.pyapplication/web/web_main.py
When a smartlink resolves to a standard section that has exactly one linked CRE, redirect the user directly to that CRE page instead of the intermediate standard-section node page. The CRE page already contains all the information the landing page would show. If multiple CREs are linked, behaviour is unchanged. Supersedes OWASP#906
91874dc to
1f5f29f
Compare
|
Verified locally by running python -m pytest application/tests/web_main_test.py::TestMain::test_smartlink -v. The current values (/cre/222-222 for CWE and /cre/333-333 for ASVS) are correct — swapping them back causes the test to fail with AssertionError: '/cre/222-222' != '/cre/333-333'. The static analysis here is incorrect; the actual runtime behavior confirms the current assertions are right. |
When a smartlink resolves to a standard section that has exactly one linked CRE, redirect the user directly to that CRE page instead of the intermediate standard-section node page. The CRE page already contains all the information the landing page would show.
If multiple CREs are linked, behaviour is unchanged.
Closes #486
Supercedes #906
Addressed the review comments in #906