Repository navigation
fix(S): 評分被拒的錯誤訊息講的是遺失物協尋(模擬器實跑抓到) - #46
Merged
Merged
Conversation
乘客對未完成/沒派到司機的行程評分,後端回的是「僅已完成的行程可申請遺失物 協尋」——狀態碼 409 正確,但文案來自遺失物功能,而它會**原樣顯示在乘客的評分 對話框上**。原因是 RateByCustomer 重用了 lost_item.go 的 ErrRideNotCompleted。 單元測試測不到:它斷言的是 errors.Is(err, ErrRideNotCompleted),訊息內容從來 沒被檢查。2026-07-27 B5 模擬器實跑打 API 時才顯現。 - 新增 ErrRideNotRatable(「僅已完成的行程可以評分」),RateByCustomer 改用它; handler 的 409 對應同步改。遺失物那條路徑不動。 - 測試補「錯誤訊息不得提到遺失物」的斷言——反向確認改回 ErrRideNotCompleted 會讓 TestRatingFlow FAIL。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
全鏈路(叫車→接單→完成→完成卡評分→DB 交叉驗證→歷史補評→司機平均分) 與四道守門的實打狀態碼;並記錄實跑抓到的遺失物文案外洩問題與其修法。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
症狀
乘客對未完成/沒派到司機的行程評分,後端回:
狀態碼 409 正確,但文案來自遺失物協尋功能——而這段訊息會原樣顯示在乘客的評分對話框上
(
rating_sheet.dart的錯誤橫幅直接顯示後端 message)。乘客想評一張已取消的行程,被告知的卻是另一個功能的規則。
機制
RatingService.RateByCustomer重用了lost_item.go的ErrRideNotCompleted:兩個功能的條件恰好相同(只有已完成且有司機的行程才適用),所以重用 sentinel 看起來很合理——
但面向使用者的文案不是共用的。
為什麼單元測試沒抓到
rating_test.go斷言的是errors.Is(err, ErrRideNotCompleted),訊息內容從來沒被檢查。sentinel 對了測試就綠,文案講什麼都無所謂。
2026-07-27 跑 B5 模擬器實跑 E2E、直接打 API 驗守門狀態碼時才顯現——
這正是 #45 裡寫的「未做:live E2E」該補的部分。
修法
ErrRideNotRatable(「僅已完成的行程可以評分」),RateByCustomer改用它;handler 的 409 對應同步改。遺失物那條路徑一行都不動。
ErrRideNotCompleted會讓
TestRatingFlowFAIL(實測--- FAIL: TestRatingFlow (25.28s))。驗收
go build/go vet/gofmt乾淨。go test ./internal/service/ -run 'TestRating|TestCustomerRideViewCarriesRating'綠(真 PostGIS)。go test ./internal/handler/ -run 'TestRateByCustomer|TestCustomerRideRoutes'綠。🤖 Generated with Claude Code