fix: more specific error message#187
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🧰 Additional context used📓 Path-based instructions (3)**/*.go📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/!(ltsm)/**/*.go📄 CodeRabbit inference engine (AGENTS.md)
Files:
pkg/connector/connector.go📄 CodeRabbit inference engine (AGENTS.md)
Files:
🔇 Additional comments (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughTwo changes to the LINE email login path: ChangesLINE Login Hardening
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
| if message == "" { | ||
| return "Could not log in to LINE. Please check your email and password and try again." | ||
| } | ||
| if strings.EqualFold(message, "Account ID or password is invalid") { |
There was a problem hiding this comment.
Brittle exact-string match: strings.EqualFold against the literal Account ID or password is invalid only fires when LINE returns that exact phrase. The data.reason field extracted by loginErrorReason is user-facing text from LINE and has historically changed wording across locales/versions; the moment it does (e.g. Invalid account ID or password, or a localized variant), this branch is skipped and users get the generic copy that this PR is specifically trying to avoid. Consider matching on a substring (strings.Contains(strings.ToLower(message), "password is invalid")) or — better — keying off the structured LINE error code if one is available upstream of loginErrorReason.
| var payload bytes.Buffer | ||
| for _, field := range []string{sessionKey, email, password} { | ||
| if len(field) > 255 { | ||
| return nil, fmt.Errorf("field is too long: %d bytes", len(field)) |
There was a problem hiding this comment.
Identify the offending field: when this fires the user / log reader has no way to tell whether the server-supplied sessionKey, their email, or their password was over 255 bytes. Swap the anonymous loop for named iterations so the error can name the field, e.g.:
for _, f := range []struct{ name, value string }{
{"sessionKey", sessionKey},
{"email", email},
{"password", password},
} {
if len(f.value) > 255 {
return nil, fmt.Errorf("%s is too long: %d bytes (max 255)", f.name, len(f.value))
}
payload.WriteByte(byte(len(f.value)))
payload.WriteString(f.value)
}(Make sure not to log the field value — only the name and length.)
No description provided.