Code Room
Vibe codingMediumvc-g216
Subject Ai code reviewLevel Mid–Senior~18 minCommon in Algorithms & data structures interviewsIndustries Software development, IT services

Question

An AI agent wrote this Python helper to redact secrets from text before it's sent to a logging-and-analytics AI assistant. It looks reasonable and the team is about to rely on it as their safety net. Identify the risks before they trust it.

python
import re SECRET_PATTERNS = [    r"sk-[a-zA-Z0-9]{20,}",      # API keys    r"AKIA[0-9A-Z]{16}",          # AWS access key id] def redact(text: str) -> str:    for pat in SECRET_PATTERNS:        text = re.sub(pat, "[REDACTED]", text)    return text # usagesafe = redact(user_text)assistant.send(safe)  # now safe to send to third-party model
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.