Skip to content

GuardrailAction is unexpectedly null when explicit filters don't match anything in the KB #3882

Open
@hughesjs

Description

@hughesjs

Describe the bug

We've just hit a NullReferenceException in our code because the nullability annotations on Amazon.BedrockAgentRuntime.Model.RetrieveAndGenerateResponse indicate that GuardrailAction is not nullable; yet it returns null in certain cases.

This seems to happen when we add manual filters for the kb that don't match anything. If there is no guardrail action and a query submits successfully GuardrailAction isn't null, and the Value is "NONE"

Image

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

response.GuardrailAction should never be null (as per nullability annotations).

GuardrailAction.Value should be "NONE" to be consistent with what happens when a successful query is sent.

Current Behavior

RetrieveAndGenerateResponse.GuardrailAction is null

Reproduction Steps

  1. Submit a RetrieveAndGenerateRequest with filters that match no objects in the kb
  2. Observe that response.GuardrailAction is null

Possible Solution

Ideally, ensure that GuardrailAction != null && GuardrailAction.Value == "NONE" in this case.

A worse solution would just be to use the nullability annotations

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.BedrockAgentRuntime v4.0.4.3

Targeted .NET Platform

dotnet 8

Operating System and version

Windows 11, Arch Linux, Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-reproductionThis issue needs reproduction.p2This is a standard priority issuequeuedservice-apiThis issue is due to a problem in a service API, not the SDK implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions