Code Room
Code reviewMediumcr-g240
Subject Jwt misuseLevel Mid–Senior~25 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Go JWT validation helper.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewgo
func parseClaims(tokenStr string, secret []byte) (jwt.MapClaims, error) {	token, err := jwt.Parse(tokenStr, func(t *jwt.Token) (interface{}, error) {		return secret, nil	})	if err != nil {		return nil, err	}	if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {		return claims, nil	}	return nil, errors.New("invalid claims")}
Run or narrate your approach, then ask the coach.