Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Silent fallbacks that hide bugs card 5 of 6

An empty list that means three things

builds on: Errors swallowed by catch-all handlers
The agent was asked to stop the sync job panicking. Its fix (BAD) turns every failure into an empty list. A missing file gives `""`, and `""` fails to parse as JSON, so that also gives `[]`. > file gone → `[]` · typo in the JSON → `[]` · file says `[]` (allow nobody) → `[]` Sync deletes every account that is not on the list. So one bad edit to the file deletes everyone. BETTER returns a `Result`: either the list or an error. `map_err` attaches which file failed. `?` means: on error, return it to the caller now. The job stops before deleting anything.
// Rust
// BAD: every failure becomes an empty list
fn allowlist(p: &Path) -> Vec<String> {
    let s = fs::read_to_string(p).unwrap_or_default();
    serde_json::from_str(&s).unwrap_or_default()
}

// BETTER: every failure reaches the caller
fn allowlist(p: &Path) -> Result<Vec<String>, String> {
    let s = fs::read_to_string(p)
        .map_err(|e| format!("{}: {e}", p.display()))?;
    serde_json::from_str(&s)
        .map_err(|e| format!("{}: {e}", p.display()))
}
Terms on this card
?
Rust operator: if a Result is an error, return that error from the current function; otherwise unwrap the value.
Result
Rust type holding either a successful value or an error; the caller must deal with both cases.
map_err
Rust method on Result: leaves a success unchanged but transforms the error, for example to add which file failed.
panicking
In Rust, a panic: the current thread stops with an error message (ending the program if it is the main thread), for example when `.unwrap()` meets an error.
JSON
JavaScript Object Notation, a common text format for structured data.
Learn this step by step on Bytewise
Lesson goal: Recognise defaults that turn a loud failure into quietly wrong data: `unwrap_or_default()`, `?? ""`, `getOrDefault`, `dict.get(k, 0)`, returning [] on a parse error. Decide when a default is genuinely correct and when the code should fail or propagate the error instead. · the whole lesson