fix(handlers): add error handling for swallowed repo/service errors

Several handler files discarded errors from repository and service
calls, creating nil-dereference risks and silent data corruption:

- guild_adventure: 3 GetByCharID calls could panic on nil guild
- gacha: GetGachaPoints silently returned zero balances on DB error
- house: HasApplication called before nil check on guild;
  GetHouseContents error discarded with 7 return values
- distitem: 3 distRepo calls had no error logging
- guild_ops: Disband/Leave service errors were invisible
- shop: gacha type/weight/fpoint lookups had no error logging
- discord: bcrypt error could result in nil password being set
This commit is contained in:
Houmgaor
2026-02-24 13:55:49 +01:00
parent 2f92b4ff62
commit 8fead0b1f3
8 changed files with 221 additions and 19 deletions

View File

@@ -53,7 +53,12 @@ func handleMsgMhfGetGachaPlayHistory(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfGetGachaPoint(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetGachaPoint)
fp, gp, gt, _ := s.server.userRepo.GetGachaPoints(s.userID)
fp, gp, gt, err := s.server.userRepo.GetGachaPoints(s.userID)
if err != nil {
s.logger.Error("Failed to get gacha points", zap.Error(err))
doAckBufSucceed(s, pkt.AckHandle, make([]byte, 12))
return
}
resp := byteframe.NewByteFrame()
resp.WriteUint32(gp)
resp.WriteUint32(gt)
@@ -159,7 +164,10 @@ func handleMsgMhfPlayStepupGacha(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfGetStepupStatus(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetStepupStatus)
status, _ := s.server.gachaService.GetStepupStatus(pkt.GachaID, s.charID, TimeAdjusted())
status, err := s.server.gachaService.GetStepupStatus(pkt.GachaID, s.charID, TimeAdjusted())
if err != nil {
s.logger.Error("Failed to get stepup status", zap.Error(err))
}
bf := byteframe.NewByteFrame()
bf.WriteUint8(status.Step)