Skip to content

fix(importer): trade-in titles in any order stay new - #1562

Merged
JOY (JOY) merged 2 commits into
devfrom
fix/1430-trade-in-phrases
Nov 1, 2026
Merged

JOY (JOY) merged 2 commits into
devfrom
fix/1430-trade-in-phrases

Conversation

@JOY

@JOY JOY (JOY) commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1430 (follow-up to #1561)

Problem

#1561 rejects a listing at ingest (NON_NEW_LISTING) when detectProductCondition(title) is not new. Its trade-in strip only covered "thu/đổi … cũ lên đời / đổi mới" and "thu (mua) máy cũ". A new device's title that offers a trade-in in another order kept the words "máy cũ", so it read as used and was dropped. Examples:

  • "… 256GB - Trợ giá lên đời máy cũ"
  • "… 256GB Lên đời máy cũ trợ giá 2 triệu"
  • "… 256GB Hỗ trợ đổi máy cũ"

Rate-Services found this before bumping its vendored copy, and it holds that bump until this lands.

Change

TRADE_IN_PHRASE (product-normalizer.ts) now strips two shapes before the condition regexes run:

  • A trade-in verb right before "(máy|điện thoại|đt) cũ": thu, thu mua, đổi, lên đời, trợ giá or hỗ trợ. A few filler words may sit between them (từ, cho, mọi, các, bằng, khi), and a trailing "lên đời" or "đổi/lấy/sang (máy) mới" goes with the phrase.
  • "(máy|điện thoại|đt) cũ" right before "lên đời" or "đổi/lấy/sang (máy) mới", as in "máy cũ lên đời" or "thu cũ đổi mới".

Tests (entity-matcher.test.ts)

  • Fourteen trade-in titles stay new, including the three above, "Thu mua giá cao máy cũ", "Trợ giá 2 triệu cho máy cũ", "Lên-đời máy cũ", "Đổi máy cũ", "Trợ giá máy cũ 1 triệu", "Thu cũ lên đời", "Máy cũ lên đời trợ giá", "Lên đời từ điện thoại cũ" and "Thu đt cũ đổi mới".
  • Seven real used titles stay used, such as "máy cũ đổi mới trong 30 ngày" (a warranty swap), "hỗ trợ máy cũ", "máy cũ đẹp", "Máy cũ giá rẻ bảo hành 3 tháng", "điện thoại cũ đã qua sử dụng", "Thanh lý máy cũ" and "máy cũ zin, trợ giá ship".
  • "Điện thoại cũ đổi mới 99%" stays like-new. The existing description and percentage fixtures still pass.
  • pnpm test (importer), tsc and eslint are clean.

Review

  • Fresh-context review: see the comment below.
  • Codex skipped (quota).

🤖 Generated with Claude Code

detectProductCondition read new-device titles such as "Trợ giá lên đời
máy cũ", "Lên đời máy cũ trợ giá" or "Hỗ trợ đổi máy cũ" as used, so
ingest threw NON_NEW_LISTING on new listings.

- The trade-in strip now takes a trade-in verb (thu, thu mua, đổi, lên
  đời, trợ giá, hỗ trợ) right before "(máy|điện thoại|đt) cũ", with a few
  filler words allowed, or "cũ" right before "lên đời" or "đổi/lấy/sang
  mới".
- Fixtures: nine trade-in titles stay new, and five real used titles stay
  used.

Refs #1430

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
rate Ready Ready Preview Nov 1, 2026 12:44am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 13045ea0-e279-47c1-8134-c94fac697cb6
Commits

Reviewing files that changed from the base of the PR and between 2877e90 and 11cd677.

Files selected for processing: 2
  • apps/importer/src/shopee/__tests__/entity-matcher.test.ts
  • apps/importer/src/shopee/product-normalizer.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

…1430 review)

- "Mới" followed by a number or a warranty term ("đổi mới 99%", "đổi mới
  trong 30 ngày") is not a trade-in, so those used listings stay used or
  like-new.
- A bare "hỗ trợ" is no longer a trade-in verb; "hỗ trợ thu/đổi" still is.
- "lại", "giá cao" and an amount ("2 triệu") may sit between the verb and
  the device, and a hyphen, colon or comma may separate the words.

Refs #1430

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dos[bot]
dos Bot approved these changes Nov 1, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⏱️ Code Review completed (2 eligible files · 3,280 chars · 4 model call(s) · 1 PR unit(s))

Whole diff with bounded context at base 2877e90 / head 5eefd84.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

@JOY

Copy link
Copy Markdown
Contributor Author

Fresh-context review (on 5eefd84). It found no P1. Fixed in 11cd677:

  • P2, used listings read as new:
    • "máy cũ đổi mới trong 30 ngày" (a warranty swap) and "Điện thoại cũ đổi mới 99%" read as new. Now "mới" followed by a number or a warranty term (trong, sau, nếu, khi) is not a trade-in.
    • "hỗ trợ máy cũ" read as new. Now a bare "hỗ trợ" is not a trade-in verb; "hỗ trợ thu" and "hỗ trợ đổi" still are.
  • P3, trade-in titles still read as used: "Thu mua giá cao máy cũ", "Thu mua lại máy cũ", "Trợ giá 2 triệu cho máy cũ" and "Lên đời - máy cũ" (with a hyphen). Now "lại", "giá cao" and an amount may sit between the verb and the device, and a hyphen, colon or comma may separate the words.
  • Left as is, because the title is ambiguous by nature:
    • " điện thoại cũ lên đời giá rẻ" and " cũ trợ giá máy cũ" read as new. The same words are a trade-in offer on a new phone's title.
    • The plausibility floor still guards min_price.
  • Regex mechanics are fine: the gi flag with replace, the String.raw escapes, and no catastrophic backtracking (a 56k-character title takes 1 ms).

Every case above is a fixture now. The importer's pnpm test, tsc and eslint are clean.

The runbook's step 1 SQL was regenerated from this source and sent to the Rate-Services audit session.

dos[bot]
dos Bot approved these changes Nov 1, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⏱️ Code Review completed (2 eligible files · 4,291 chars · 2 model call(s) · 1 PR unit(s))

Whole diff with bounded context at base 2877e90 / head 11cd677.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

@JOY
JOY (JOY) merged commit d0b1034 into dev Nov 1, 2026
15 checks passed
@JOY
JOY (JOY) deleted the fix/1430-trade-in-phrases branch November 1, 2026 00:53

This branch was successfully deployed

1 active deployment
Preview — 11cd6773 Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant