Code Room
Vibe codingHardvc-g281
Subject Ai refactor migrationLevel Senior–Staff~22 minCommon in Code quality & review interviewsIndustries Software development

Question

You're migrating an Android service layer from Java to Kotlin and let an AI agent auto-convert files. The converted Kotlin compiles and you ship it to the beta channel, where you start seeing a spike in NullPointerExceptions that the old Java code 'never had.' Below is the kind of signature the agent produced — explain the trap.

kotlin
// Java method returned a value annotated @Nullable in some callers' minds// but had no annotation. Agent converted it as:fun loadProfile(id: String): UserProfile {  // non-null return type    return repository.find(id)  // can return null at runtime}
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.