Skip to content

Conversation

@xinquiry
Copy link
Collaborator

@xinquiry xinquiry commented Jan 21, 2026

Summary

  • Restore the redemption router prefix from /business back to /redemption in the backend
  • Update redemptionService.ts to use /redemption/ paths consistently

This fixes the 404 error when accessing the admin dashboard at /#secretcode and trying to login.

Root Cause

Commit 475cd62 changed the router prefix from /redemption to /business, but the admin components (SecretCodePage.tsx, CodesList.tsx, CodeGenerationForm.tsx) still use hardcoded /redemption/ paths.

Test plan

  • Navigate to /#secretcode
  • Enter admin secret key
  • Verify login succeeds without 404 errors
  • Verify codes list loads correctly

🤖 Generated with Claude Code

Summary by Sourcery

将兑换(redemption)API 的路由前缀,从 /business 恢复为 /redemption,并在后端与前端的服务调用中统一使用该前缀,从而修复管理后台的兑换流程。

Bug 修复:

  • 通过将前端服务的 URL 与恢复后的后端 /redemption 路由保持一致,修复管理端兑换接口返回 404 的问题。

增强内容:

  • 重新标记后端兑换路由器,使其使用独立的 /redemption 前缀和标签,以实现更清晰的 API 职责分离。
Original summary in English

Summary by Sourcery

Restore the redemption API routing prefix from /business back to /redemption across backend and frontend service calls to fix admin dashboard redemption flows.

Bug Fixes:

  • Fix admin redemption endpoints returning 404 by aligning frontend service URLs with the restored /redemption backend routes.

Enhancements:

  • Retag backend redemption router to use a dedicated /redemption prefix and tag for clearer API separation.

      The router prefix was changed from /redemption to /business in commit 475cd62,
      but the admin components still use /redemption paths, causing 404 errors
      when accessing the admin dashboard at /#secretcode.

      This restores the original /redemption prefix for consistency.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 21, 2026

评审者指南(在小型 PR 上折叠)

评审者指南

将后端兑换路由前缀恢复为 /redemption,并使所有前端兑换服务调用统一使用 /redemption API 路径而非 /business,从而修复管理员密钥登录流程中的 404 问题。

通过 /redemption API 进行管理员密钥登录的时序图

sequenceDiagram
    actor Admin
    participant SecretCodePage
    participant RedemptionService
    participant BackendAPI
    participant RedemptionRouter

    Admin->>SecretCodePage: Enter_secret_code_and_submit
    SecretCodePage->>RedemptionService: redeemCode(code)
    RedemptionService->>BackendAPI: POST /xyzen/api/v1/redemption/redeem
    BackendAPI->>RedemptionRouter: Route_request_to_redemption_router
    RedemptionRouter-->>BackendAPI: Redeem_response
    BackendAPI-->>RedemptionService: 200_OK_with_auth_and_admin_data
    RedemptionService-->>SecretCodePage: RedeemCodeResponse
    SecretCodePage-->>Admin: Login_success_and_admin_dashboard_loaded
Loading

按文件划分的更改

更改 详情 文件
将兑换 API 路由从 /business 恢复为 /redemption,并更新所有对应的前端服务端点。
  • 将 FastAPI v1 路由修改为在 /redemption 前缀下挂载兑换路由,并更新标签名称以匹配资源域。
  • 将前端服务层中所有与兑换相关的请求 URL 更新为使用 /xyzen/api/v1/redemption/... 路径,而不是 /xyzen/api/v1/business/...,覆盖兑换、钱包、记录以及管理员统计等端点。
  • 更新 lockfile,以反映与此次路由调整相关的后端依赖/环境变化。
service/app/api/v1/__init__.py
web/src/service/redemptionService.ts
service/uv.lock

提示与命令

与 Sourcery 交互

  • 触发新的评审: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub Issue: 在评审评论下回复,要求 Sourcery 从该评论创建 issue。你也可以直接回复 @sourcery-ai issue,从该评审评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成评审者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成评审者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 关闭所有 Sourcery 评审: 在 pull request 中评论 @sourcery-ai dismiss,即可关闭所有现有的 Sourcery 评审。特别适用于你希望从一次全新的评审开始——记得再评论 @sourcery-ai review 来触发新的评审!

自定义你的使用体验

访问你的 控制台 以:

  • 启用或禁用评审功能,例如 Sourcery 生成的 pull request 摘要、评审者指南等。
  • 更改评审语言。
  • 添加、删除或编辑自定义评审说明。
  • 调整其他评审设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Restores the backend redemption router prefix to /redemption and aligns all frontend redemption service calls to use the /redemption API paths instead of /business, fixing 404s in the admin secret-code flow.

Sequence diagram for admin secret code login via /redemption API

sequenceDiagram
    actor Admin
    participant SecretCodePage
    participant RedemptionService
    participant BackendAPI
    participant RedemptionRouter

    Admin->>SecretCodePage: Enter_secret_code_and_submit
    SecretCodePage->>RedemptionService: redeemCode(code)
    RedemptionService->>BackendAPI: POST /xyzen/api/v1/redemption/redeem
    BackendAPI->>RedemptionRouter: Route_request_to_redemption_router
    RedemptionRouter-->>BackendAPI: Redeem_response
    BackendAPI-->>RedemptionService: 200_OK_with_auth_and_admin_data
    RedemptionService-->>SecretCodePage: RedeemCodeResponse
    SecretCodePage-->>Admin: Login_success_and_admin_dashboard_loaded
Loading

File-Level Changes

Change Details Files
Restore redemption API routing from /business back to /redemption and update all corresponding frontend service endpoints.
  • Change FastAPI v1 router to mount the redemption router under the /redemption prefix with an updated tag name to match the resource domain.
  • Update all redemption-related fetch URLs in the frontend service layer to use /xyzen/api/v1/redemption/... paths instead of /xyzen/api/v1/business/..., covering redeem, wallet, history, and admin stats endpoints.
  • Update the lockfile to reflect backend dependency/environment changes associated with the routing adjustment.
service/app/api/v1/__init__.py
web/src/service/redemptionService.ts
service/uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - 我发现了 1 个问题,并留下了一些高层次的反馈:

  • 由于前端和后端都依赖 /redemption 这个基础路径,建议在 redemptionService.ts 中把这个前缀提取成一个共享常量(或配置),以避免未来路径变更时出现不一致。
  • 将路由的 tag 从 business 重命名为 redemption 可能会影响依赖这些 tag 的工具(例如 OpenAPI 客户端或过滤器);如果这是有意为之,建议在同一个改动中,将所有基于 tag 的用法也一并调整为新名称。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- Since the frontend and backend both depend on the `/redemption` base path, consider extracting this prefix into a shared constant (or config) in `redemptionService.ts` to avoid future mismatches when paths change.
- Renaming the router tag from `business` to `redemption` may affect tools that rely on tags (e.g., OpenAPI clients or filters); if that impact is intentional, consider aligning any tag-based usage to the new name in the same change.

## Individual Comments

### Comment 1
<location> `web/src/service/redemptionService.ts:98-101` </location>
<code_context>
   async redeemCode(code: string): Promise<RedeemCodeResponse> {
     const response = await fetch(
-      `${this.getBackendUrl()}/xyzen/api/v1/business/redeem`,
+      `${this.getBackendUrl()}/xyzen/api/v1/redemption/redeem`,
       {
         method: "POST",
</code_context>

<issue_to_address>
**suggestion:** Consider centralizing the `/xyzen/api/v1/redemption` base path to reduce duplication and mismatch risk.

Each method now repeats the full `/xyzen/api/v1/redemption/...` URL. Defining a shared base (e.g. `const baseRedemptionPath = 
  `${this.getBackendUrl()}/xyzen/api/v1/redemption`;`) and appending per-endpoint paths would make future URL changes safer and reduce the risk of endpoints drifting out of sync.

Suggested implementation:

```typescript
  async redeemCode(code: string): Promise<RedeemCodeResponse> {
    const baseRedemptionPath = `${this.getBackendUrl()}/xyzen/api/v1/redemption`;
    const response = await fetch(
      `${baseRedemptionPath}/redeem`,
      {
        method: "POST",
        headers: this.createAuthHeaders(),

```

```typescript
  async getUserWallet(): Promise<UserWalletResponse> {
    const baseRedemptionPath = `${this.getBackendUrl()}/xyzen/api/v1/redemption`;
    const response = await fetch(
      `${baseRedemptionPath}/wallet`,
      {
        method: "GET",
        headers: this.createAuthHeaders(),

```

If there are other methods in this file (or related services) that call `/xyzen/api/v1/redemption/...`, they should also be updated to:
1. Define `const baseRedemptionPath = \`${this.getBackendUrl()}/xyzen/api/v1/redemption\`;` at the top of the method.
2. Build their endpoint URLs as `\`${baseRedemptionPath}/<endpoint>\`` rather than hardcoding the full string.

If the pattern is used in many places across the class, you may want to further centralize this into a private helper (e.g. `private getRedemptionBasePath(): string`) and replace the per-method `const` with calls to that helper.
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得我们的 Review 有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的 Review。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • Since the frontend and backend both depend on the /redemption base path, consider extracting this prefix into a shared constant (or config) in redemptionService.ts to avoid future mismatches when paths change.
  • Renaming the router tag from business to redemption may affect tools that rely on tags (e.g., OpenAPI clients or filters); if that impact is intentional, consider aligning any tag-based usage to the new name in the same change.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since the frontend and backend both depend on the `/redemption` base path, consider extracting this prefix into a shared constant (or config) in `redemptionService.ts` to avoid future mismatches when paths change.
- Renaming the router tag from `business` to `redemption` may affect tools that rely on tags (e.g., OpenAPI clients or filters); if that impact is intentional, consider aligning any tag-based usage to the new name in the same change.

## Individual Comments

### Comment 1
<location> `web/src/service/redemptionService.ts:98-101` </location>
<code_context>
   async redeemCode(code: string): Promise<RedeemCodeResponse> {
     const response = await fetch(
-      `${this.getBackendUrl()}/xyzen/api/v1/business/redeem`,
+      `${this.getBackendUrl()}/xyzen/api/v1/redemption/redeem`,
       {
         method: "POST",
</code_context>

<issue_to_address>
**suggestion:** Consider centralizing the `/xyzen/api/v1/redemption` base path to reduce duplication and mismatch risk.

Each method now repeats the full `/xyzen/api/v1/redemption/...` URL. Defining a shared base (e.g. `const baseRedemptionPath = 
  `${this.getBackendUrl()}/xyzen/api/v1/redemption`;`) and appending per-endpoint paths would make future URL changes safer and reduce the risk of endpoints drifting out of sync.

Suggested implementation:

```typescript
  async redeemCode(code: string): Promise<RedeemCodeResponse> {
    const baseRedemptionPath = `${this.getBackendUrl()}/xyzen/api/v1/redemption`;
    const response = await fetch(
      `${baseRedemptionPath}/redeem`,
      {
        method: "POST",
        headers: this.createAuthHeaders(),

```

```typescript
  async getUserWallet(): Promise<UserWalletResponse> {
    const baseRedemptionPath = `${this.getBackendUrl()}/xyzen/api/v1/redemption`;
    const response = await fetch(
      `${baseRedemptionPath}/wallet`,
      {
        method: "GET",
        headers: this.createAuthHeaders(),

```

If there are other methods in this file (or related services) that call `/xyzen/api/v1/redemption/...`, they should also be updated to:
1. Define `const baseRedemptionPath = \`${this.getBackendUrl()}/xyzen/api/v1/redemption\`;` at the top of the method.
2. Build their endpoint URLs as `\`${baseRedemptionPath}/<endpoint>\`` rather than hardcoding the full string.

If the pattern is used in many places across the class, you may want to further centralize this into a private helper (e.g. `private getRedemptionBasePath(): string`) and replace the per-method `const` with calls to that helper.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Mile-Away Mile-Away merged commit 7cf22ff into main Jan 21, 2026
10 checks passed
@Mile-Away Mile-Away deleted the fix/restore-redemption-api-path branch January 21, 2026 12:17
Mile-Away pushed a commit that referenced this pull request Jan 21, 2026
## [1.0.6](v1.0.5...v1.0.6) (2026-01-21)

### 🐛 Bug Fixes

* restore redemption API path from /business to /redemption ([#191](#191)) ([7cf22ff](7cf22ff))
@Mile-Away
Copy link
Contributor

🎉 This PR is included in version 1.0.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants