Skip to content

Feature/channel retry warning - #2987

Merged
Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
seefs001:feature/channel-retry-warning
Feb 22, 2026
Merged

Feature/channel retry warning#2987
Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
seefs001:feature/channel-retry-warning

Conversation

@seefs001

@seefs001 seefs001 commented Feb 22, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Release Notes

  • New Features

    • Added confirmation workflow for channel status code redirect configurations with risk acknowledgement to ensure safe configuration changes
    • Status codes 504 and 524 are now explicitly excluded from retry logic and cannot be configured to retry
  • Documentation

    • Updated UI helper text to clarify that status codes 504 and 524 cannot be retried and are not affected by retry configuration settings

@coderabbitai

coderabbitai Bot commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR implements a risk acknowledgment workflow for high-risk HTTP status code redirects (504, 524) that should never be retried. It refactors backend retry logic to use a centralized helper function, introduces a reusable risk acknowledgment modal component, integrates it into channel editing workflows, and adds multi-language i18n support.

Changes

Cohort / File(s) Summary
Backend retry logic refactoring
controller/relay.go, setting/operation_setting/status_code_ranges.go, setting/operation_setting/status_code_ranges_test.go
Introduced centralized helper IsAlwaysSkipRetryStatusCode() for checking non-retriable status codes (504, 524); refactored shouldRetry() to use this helper instead of explicit status code checks; added corresponding unit tests.
Core risk acknowledgment modal
web/src/components/common/modals/RiskAcknowledgementModal.jsx
New generic React modal component supporting checklist validation, required text input matching, markdown risk content rendering, detail items display, and responsive styling for mobile/desktop contexts.
Status code risk guard components
web/src/components/table/channels/modals/StatusCodeRiskGuardModal.jsx, web/src/components/table/channels/modals/statusCodeRiskGuard.js
New status-code-specific modal wrapper with i18n support; utility module defining non-redirectable status codes, risk detection logic via collectNewDisallowedStatusCodeRedirects(), and checklist/i18n key constants.
Channel editor integration
web/src/components/table/channels/modals/EditChannelModal.jsx
Integrated status code risk guard into submit flow with async confirmation resolver pattern; tracks initial status-code mappings to detect newly risky redirects; blocks submission pending user confirmation.
Internationalization
web/src/i18n/locales/en.json, web/src/i18n/locales/zh-CN.json, web/src/i18n/locales/zh-TW.json
Added 13 new translation keys per locale covering risk acknowledgment modal titles, checklist items, input prompts, markdown risk disclaimers, and status code retry behavior notes.
UI text updates
web/src/pages/Setting/Operation/SettingsMonitoring.jsx
Appended helper text note clarifying that 504 and 524 are never retried regardless of configuration.

Sequence Diagram

sequenceDiagram
    actor User
    participant EditChannelModal
    participant statusCodeRiskGuard
    participant StatusCodeRiskGuardModal
    participant RiskAcknowledgementModal
    participant Backend

    User->>EditChannelModal: Edit channel & modify status_code_mapping
    User->>EditChannelModal: Click Submit
    EditChannelModal->>statusCodeRiskGuard: collectNewDisallowedStatusCodeRedirects(original, current)
    statusCodeRiskGuard-->>EditChannelModal: [risky redirect mappings]
    alt Risky Redirects Detected
        EditChannelModal->>StatusCodeRiskGuardModal: Show with detailItems=riskyRedirects
        StatusCodeRiskGuardModal->>RiskAcknowledgementModal: Render with checklist + required text
        RiskAcknowledgementModal-->>User: Display warning modal with risk content
        User->>RiskAcknowledgementModal: Check all items & type confirmation text
        RiskAcknowledgementModal->>StatusCodeRiskGuardModal: Resolve confirmation promise
        StatusCodeRiskGuardModal->>EditChannelModal: onConfirm callback fired
        EditChannelModal->>Backend: Submit channel update
    else No Risky Redirects
        EditChannelModal->>Backend: Submit channel update directly
    end
    Backend-->>User: Update successful
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • Calcium-Ion
  • creamlike1024

Poem

🐰 Hoppy PR hops through the stack,
Risk checks now centralized, no turning back!
504s and 524s shake their heads—
"Never retry!" the modal thread spreads. 🚫
Modal chains confirm the risky dance,
Users check twice before taking chance!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feature/channel retry warning' is directly related to the main change: introducing risk acknowledgement warnings for high-risk status code retries (504/524) in channel configurations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
setting/operation_setting/status_code_ranges.go (1)

29-32: Consider marking alwaysSkipRetryStatusCodes as intentionally immutable.

Since Go doesn't allow const maps, there's no compiler-enforced guarantee. The map is currently safe (unexported, no setter, never written after init), but a brief comment prevents future maintainers from adding entries at runtime without also updating ShouldRetryByStatusCode's callers.

💡 Suggested annotation
-var alwaysSkipRetryStatusCodes = map[int]struct{}{
+// alwaysSkipRetryStatusCodes lists HTTP status codes that are NEVER retried,
+// regardless of AutomaticRetryStatusCodeRanges. Do NOT modify at runtime.
+var alwaysSkipRetryStatusCodes = map[int]struct{}{
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@setting/operation_setting/status_code_ranges.go` around lines 29 - 32, Add an
explicit comment above the alwaysSkipRetryStatusCodes map stating it is
intentionally immutable (e.g., "immutable: do not modify at runtime; update
ShouldRetryByStatusCode callers if you change this") so future maintainers know
not to mutate it; keep the map unexported and leave ShouldRetryByStatusCode as
the single read-path that consults this map.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/components/common/modals/RiskAcknowledgementModal.jsx`:
- Around line 139-147: The empty styled warning container inside
RiskAcknowledgementModal (the div with className 'rounded-lg' and inline styles
using isMobile) should be removed or populated; either delete that div entirely
to avoid rendering a blank block, or add the intended warning content (e.g., the
modal’s warning title/message or an i18n string) inside it so the banner
displays meaningful text and actions; locate this div in
RiskAcknowledgementModal.jsx (the element using isMobile for padding) and
implement the chosen change.

---

Nitpick comments:
In `@setting/operation_setting/status_code_ranges.go`:
- Around line 29-32: Add an explicit comment above the
alwaysSkipRetryStatusCodes map stating it is intentionally immutable (e.g.,
"immutable: do not modify at runtime; update ShouldRetryByStatusCode callers if
you change this") so future maintainers know not to mutate it; keep the map
unexported and leave ShouldRetryByStatusCode as the single read-path that
consults this map.

Comment on lines +139 to +147
<div
className='rounded-lg'
style={{
border: '1px solid var(--semi-color-warning-light-hover)',
background: 'var(--semi-color-warning-light-default)',
padding: isMobile ? '10px 12px' : '12px 14px',
}}
>
</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove or populate the empty warning banner.
Lines 139-147 render a styled container with no content, which shows as a blank block in the modal.

🧹 Proposed cleanup
-        <div
-          className='rounded-lg'
-          style={{
-            border: '1px solid var(--semi-color-warning-light-hover)',
-            background: 'var(--semi-color-warning-light-default)',
-            padding: isMobile ? '10px 12px' : '12px 14px',
-          }}
-        >
-        </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
className='rounded-lg'
style={{
border: '1px solid var(--semi-color-warning-light-hover)',
background: 'var(--semi-color-warning-light-default)',
padding: isMobile ? '10px 12px' : '12px 14px',
}}
>
</div>
{/* warning banner removed - was empty */}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/common/modals/RiskAcknowledgementModal.jsx` around lines
139 - 147, The empty styled warning container inside RiskAcknowledgementModal
(the div with className 'rounded-lg' and inline styles using isMobile) should be
removed or populated; either delete that div entirely to avoid rendering a blank
block, or add the intended warning content (e.g., the modal’s warning
title/message or an i18n string) inside it so the banner displays meaningful
text and actions; locate this div in RiskAcknowledgementModal.jsx (the element
using isMobile for padding) and implement the chosen change.

@Calcium-Ion
Calcium-Ion merged commit 3523947 into QuantumNous:main Feb 22, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…ry-warning

Feature/channel retry warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants