Skip to content

opensearch: invalid search queries return 500 #3312

Closed

Description

@v-scharf

Describe the bug

A clear and concise description of what the bug is.

run opencloud against https://github.com/opencloud-eu/opencloud-compose COMPOSE_FILE=docker-compose.yml:traefik/opencloud.yml:search/opensearch.yml:search/tika.yml

Steps to reproduce

  • USE_BEARER_TOKEN=true TEST_SERVER_URL=https://cloud.opencloud.test BEHAT_FEATURE=tests/acceptance/features/apiSearch1/search.feature:324 make test-acceptance-api
Scenario: try to search with invalid patterns
    Given using spaces DAV path
    And user "Alice" has uploaded file with content "test file" to "testFile.txt"
    When user "Alice" searches for 'AND mediatype:document' using the WebDAV API
    Then the HTTP status code should be "400"
    And the value of the item "/d:error/s:message" in the response should be "error: bad request: the expression can't begin from a binary operator: 'AND'"

Expected behavior

400 with error message. like: error: bad request: the expression can't begin from a binary operator: 'AND'

Actual behavior

HTTP status code 500 is not the expected value 400
error log:

{"level":"error","service":"search","error":"failed to convert KQL query to OpenSearch bool query: failed to build query: the expression can't begin from a binary operator: 'AND'","duration":"50.625µs","space":"16f09616-9129-4958-abf1-d9ac16dade0e$c91a102b-6853-4511-bb01-0bc4d51082db!c91a102b-6853-4511-bb01-0bc4d51082db","time":"2026-08-14T11:59:15Z","line":"github.com/opencloud-eu/opencloud/services/search/pkg/search/service.go:408","message":"failed to search the index"}

{"level":"error","service":"webdav","request-id":"","error":"{\"id\":\"eu.opencloud.api.search\",\"code\":500,\"detail\":\"failed to convert KQL query to OpenSearch bool query: failed to build query: the expression can't begin from a binary operator: 'AND'\",\"status\":\"Internal Server Error\"}","time":"2026-08-14T11:59:15Z","line":"github.com/opencloud-eu/opencloud/services/webdav/pkg/service/v0/search.go:112","message":"could not get search results"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions