sendMockNotFoundError builds a ParserError from a mock-miss error, extracting the MismatchReport if the error carries one.
(err error)
| 3044 | // sendMockNotFoundError builds a ParserError from a mock-miss error, |
| 3045 | // extracting the MismatchReport if the error carries one. |
| 3046 | func (p *Proxy) sendMockNotFoundError(err error) { |
| 3047 | proxyErr := models.ParserError{ |
| 3048 | ParserErrorType: models.ErrMockNotFound, |
| 3049 | Err: err, |
| 3050 | } |
| 3051 | // Extract diff report from the error chain if available. |
| 3052 | // Use errors.As to traverse wrapped errors. |
| 3053 | type mismatchReporter interface { |
| 3054 | MismatchReport() *models.MockMismatchReport |
| 3055 | } |
| 3056 | var reporter mismatchReporter |
| 3057 | if errors.As(err, &reporter) && reporter != nil { |
| 3058 | proxyErr.MismatchReport = reporter.MismatchReport() |
| 3059 | } |
| 3060 | // Single, protocol-agnostic mock-mismatch log. EVERY parser's MockOutgoing |
| 3061 | // miss funnels through here, so this one line covers HTTP, generic, MySQL, |
| 3062 | // gRPC, etc. uniformly — it names WHICH upstream missed and how far matching |
| 3063 | // got, instead of each parser logging it differently (or not at all). The |
| 3064 | // per-parser decode loggers stay at Debug to avoid double-logging. |
| 3065 | if r := proxyErr.MismatchReport; r != nil { |
| 3066 | p.logger.Warn("mock mismatch: no matching mock for outgoing call", |
| 3067 | zap.String("protocol", r.Protocol), |
| 3068 | zap.String("destination", r.Destination), |
| 3069 | zap.String("actual", r.ActualSummary), |
| 3070 | zap.String("match_phase", r.MatchPhase), |
| 3071 | zap.Int("candidates", r.CandidateCount), |
| 3072 | zap.String("closest", r.ClosestMock), |
| 3073 | zap.String("next_step", r.NextSteps)) |
| 3074 | } else { |
| 3075 | p.logger.Warn("mock mismatch: no matching mock for outgoing call (no structured report)", zap.Error(err)) |
| 3076 | } |
| 3077 | p.SendError(proxyErr) |
| 3078 | } |
| 3079 | |
| 3080 | // CloseErrorChannel closes the error channel |
| 3081 | func (p *Proxy) CloseErrorChannel() { |
no test coverage detected