Skip to content

❤ fix(topup): prevent nil-pointer in Epay callback; reset page on search - #1977

Merged
seefs001 merged 1 commit into
mainfrom
fix/bills
Oct 7, 2025
Merged

❤ fix(topup): prevent nil-pointer in Epay callback; reset page on search#1977
seefs001 merged 1 commit into
mainfrom
fix/bills

Conversation

@t0ng7u

@t0ng7u t0ng7u commented Oct 7, 2025

Copy link
Copy Markdown
Collaborator

Add early return when Epay client is missing in controller/topup.go to avoid panic Introduce handleKeywordChange in TopupHistoryModal.jsx to reset page to 1 when keyword updates Wire input onChange to new handler; minor UX improvement to avoid empty results on pagination mismatch

Summary by CodeRabbit

  • New Features
    • Top-up history search now resets to the first page when you change the keyword, improving result relevance.
  • Bug Fixes
    • Improved handling of payment notifications when the payment provider isn’t configured, reducing erroneous responses and processing.

Add early return when Epay client is missing in controller/topup.go to avoid panic
Introduce handleKeywordChange in TopupHistoryModal.jsx to reset page to 1 when keyword updates
Wire input onChange to new handler; minor UX improvement to avoid empty results on pagination mismatch
@coderabbitai

coderabbitai Bot commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Two changes: backend handler EpayNotify now always returns after writing "fail" when the Epay client is nil; frontend TopupHistoryModal introduces a handleKeywordChange function to update the keyword and reset pagination to page 1, adjusting the Input onChange flow accordingly.

Changes

Cohort / File(s) Summary of changes
Payment notification control flow
controller/topup.go
Moved return outside the inner error-check: when Epay client is nil, write "fail" and unconditionally return from EpayNotify.
Top-up history search handling
web/src/components/topup/modals/TopupHistoryModal.jsx
Added handleKeywordChange(value) to set keyword and reset page to 1; Input onChange now calls this handler instead of setKeyword directly.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Handler as EpayNotify Handler
  participant EpayClient as Epay Client (optional)

  Client->>Handler: HTTP notify
  alt Epay client configured
    Handler->>EpayClient: Process notification
    EpayClient-->>Handler: Result
    Handler-->>Client: Response (per result)
  else Epay client is nil
    rect rgba(230, 230, 255, 0.4)
      note right of Handler: Changed flow
      Handler-->>Client: "fail"
      Handler-->>Client: Return immediately
    end
  end
Loading
sequenceDiagram
  autonumber
  actor User
  participant Input as Search Input
  participant Modal as TopupHistoryModal State
  participant Pager as Pagination

  User->>Input: Type keyword
  Input->>Modal: onChange(value)
  rect rgba(230, 255, 230, 0.4)
    note right of Modal: New handler
    Modal->>Modal: handleKeywordChange(value)
    Modal->>Modal: setKeyword(value)
    Modal->>Pager: setCurrentPage(1)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A twitch of whiskers, a hop through code,
I nudge the flow where payments rode—
“Fail,” then flee, the handler’s done,
While searches start at page one.
Carrots compiled, I thump with glee,
Small tweaks made neat as burrowed tea. 🥕✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 succinctly describes both primary fixes in the PR—avoiding a nil-pointer in the Epay callback and resetting the page on search—using clear conventional commit syntax, though the leading heart emoji adds unnecessary noise.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/bills

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec590d1 and ddf5c85.

📒 Files selected for processing (2)
  • controller/topup.go (1 hunks)
  • web/src/components/topup/modals/TopupHistoryModal.jsx (2 hunks)
🔇 Additional comments (3)
web/src/components/topup/modals/TopupHistoryModal.jsx (2)

105-108: LGTM! Pagination reset on search is a solid UX improvement.

The handler correctly resets the page to 1 when the keyword changes, preventing empty results when searching while on a higher page number. This ensures users always see results if they exist.


239-239: LGTM! Input correctly wired to the new handler.

The onChange callback now triggers the pagination reset logic whenever the user types in the search field.

controller/topup.go (1)

241-241: Critical fix! Prevents nil-pointer panic.

Previously, when the Epay client configuration was missing, the code would attempt to write "fail" but then continue executing to Line 243 where client.Verify(params) would panic with a nil-pointer dereference. This return statement correctly exits the handler early when the configuration is unavailable.


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.

@seefs001
seefs001 merged commit a610ef4 into main Oct 7, 2025
1 check passed
@Calcium-Ion
Calcium-Ion deleted the fix/bills branch October 11, 2025 03:06
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
❤ fix(topup): prevent nil-pointer in Epay callback; reset page on search
jiutubaba pushed a commit to jiutubaba/fx-api that referenced this pull request May 17, 2026
feat: 支持 Vertex Service Account(Anthropic / Gemini)
jiutubaba pushed a commit to jiutubaba/fx-api that referenced this pull request May 17, 2026
…ous#1977)

- Security: force token_uri to Google default, preventing SSRF via crafted service account JSON
- Dedup: extract shared getVertexServiceAccountAccessToken() to eliminate ~35 lines of duplication between ClaudeTokenProvider and GeminiTokenProvider
- Fix: apply model mapping + Vertex model ID normalization in forward_as_responses and forward_as_chat_completions paths
- Fix: exclude service_account from AI Studio endpoint selection (Vertex cannot serve generativelanguage.googleapis.com)
- Feature: add model restriction/mapping UI for service_account in EditAccountModal
- Dedup: extract VERTEX_LOCATION_OPTIONS to shared constants
- i18n: replace all hardcoded Chinese strings in Vertex UI with translation keys
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