Skip to content

turnloop-mongodb: WriteResult::parse only reports failure when ok == 0, missing duplicate-key writeErrors #72

Description

@proggeramlug

Problem

WriteResult::parse only reports a write as failed when the response's ok field is 0. But a duplicate-key error on an insert answers ok: 1 together with a writeErrors array describing the actual failure — so a host that trusts WriteResult::parse's pass/fail verdict alone will silently treat a failed insert as successful.

Why it matters

This is exactly the kind of defect that is invisible until it happens in production: the server told the driver about the failure (writeErrors), but the crate's own summary type didn't surface it. Perry's P7 lane flagged that the safe order — checking Error::from_response before trusting WriteResult::parse's verdict — "is not stated anywhere" in the crate's documentation.

What would fix it

Either WriteResult::parse itself should check for a non-empty writeErrors array and treat that as failure regardless of ok, or, short of that, the crate's documentation should state explicitly that callers must check Error::from_response first and cannot rely on WriteResult::parse's verdict alone.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions