SAP / SAP/ai-sdk-java

VectorSearchFilter.filter serializes as null causing HTTP 400 from AI Core API

Open
#857 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
43
Forks
22
Avg merge
16h 25m
Merged PRs (30d)
59

Description

Describe the Problem/Bug

When using VectorApi.search(), the VectorSearchFilter class has a filter field annotated with @JsonProperty("filter") but without @JsonInclude(JsonInclude.Include.NON_NULL). When filter is not set (the
common case), it serializes as "filter": null in the JSON request body.

The AI Core API rejects this with HTTP 400:
{"error": {"code": "400", "message": "None is not valid under any of the given schemas - 'filters.0.filter'"}}

Steps to Reproduce
  var filter = VectorSearchFilter.create()
      .id(UUID.randomUUID().toString())
      .collectionIds(List.of("*"))
      ._configuration(VectorSearchConfiguration.create().maxDocumentCount(5));

  var request = TextSearchRequest.create()
      .query("some query")
      .filters(filter);

  vectorApi.search(resourceGroupId, request); // → HTTP 400

Actual request body sent:

  {
    "query": "some query",
    "filters": [{
      "id": "...",
      "collectionIds": ["*"],
      "configuration": {"maxDocumentCount": 5},
      "collectionMetadata": [],
      "documentMetadata": [],
      "chunkMetadata": [],
      "filter": null
    }]
  }
Expected Behavior

filter should be omitted from the serialized JSON when not set, either via @JsonInclude(JsonInclude.Include.NON_NULL) on the field, or by configuring the SDK's default ObjectMapper with
NON_NULL inclusion.

Workaround: Construct the VectorApi with a custom ApiClient using an ObjectMapper configured with JsonInclude.Include.NON_NULL.

Screenshots

No response

Used Versions

SDK version: 1.19.0
Spring AI version: 1.1.5

Code Examples
// Your code here
Stack Trace

No response

Log File
Log file ...
Affected Development Phase

Getting Started

Impact

No Impact

Timeline

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with VectorSearchFilter and inspect how its filter field is serialized, then compare the default ApiClient ObjectMapper with the custom NON_NULL workaround described in the issue. Reproduce the VectorApi.search() request and confirm that an unset filter is omitted and the AI Core API no longer returns HTTP 400.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.