The exact meaning of the original language is uncertain. Some Bibles translate "How painful" as "How pleasant." Alternate translation: "When a person speaks the truth, it harms no one. But your arguments are not true, so how do they actually rebuke me?"
The word "upright" here is a metaphor for honesty or truthfulness. Alternate translation: "honest words" or "truthful words" (See: [[rc://en/ta/man/jit/figs-metaphor]])
Job is using this question to rebuke his friends and to emphasize that what they are saying does not apply to him. This question can be written as a statement. Alternate translation: "Your reasons for rebuking me do not apply to me even though you sternly correct me." or "But your arguments against me are not true, so they do not actually rebuke me!" (See: [[rc://en/ta/man/jit/figs-rquestion]])