Code Room
Code reviewMediumcr-g536
Subject Code reviewLevel Mid–Senior~18 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Python function that truncates a user comment to fit a 100-byte DB column and streams it.

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 reviewpython
def truncate_comment(text: str, max_bytes: int = 100) -> bytes:    encoded = text.encode("utf-8")    if len(encoded) <= max_bytes:        return encoded    return encoded[:max_bytes]
Run or narrate your approach, then ask the coach.