Skip to content

bug(rust): Bedrock embedding path panics on malformed payload and runtime blocking assumptions #3506

Description

@UTSAVS26

LanceDB version

0.30.1-beta.2 (from Cargo.toml)

What happened?

The Bedrock embedding compute path can panic instead of returning a typed error.

Exact cause

  1. Runtime-sensitive blocking path is used at bedrock.rs, then unwrapped.
  2. Request serialization uses unwrap at bedrock.rs.
  3. Response vector conversion unwraps numeric casting at bedrock.rs.

Expected behavior

Malformed payloads, non-numeric embedding values, or runtime incompatibility should return typed errors (for example Error::Runtime) and never panic.

Impact

  1. Panic can terminate request workers/process paths.
  2. Production reliability degrades under provider response drift.
  3. Error handling and observability are weaker than typed error propagation.

Are there known steps to reproduce?

  1. Configure Bedrock embedding provider and call embedding compute.
  2. Trigger one of:
    • non-numeric values inside returned embedding array
    • runtime setup incompatible with blocking path
    • malformed/unexpected response shape
  3. Observe panic instead of graceful typed error.

Proposed improvement

  1. Replace panic-prone unwraps in Bedrock embedding flow with explicit Result error mapping.
  2. Validate response schema and numeric element types before conversion.
  3. Remove/guard runtime blocking assumptions so incompatible runtime contexts return typed errors.
  4. Add tests for malformed JSON, non-numeric embeddings, and runtime mismatch to ensure no panic paths.

Acceptance criteria

  1. No panic for malformed/non-numeric Bedrock responses.
  2. Runtime incompatibility returns typed errors.
  3. Regression tests cover malformed JSON, non-numeric vectors, and runtime mismatch scenarios.

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