8000 [Bug]: array values in filter_query silently filter on the last value only · Issue #966 · storyblok/monoblok · GitHub
[go: up one dir, main page]

Skip to content

[Bug]: array values in filter_query silently filter on the last value only #966

Done

Description

@Lorti

Package

@storyblok/api-client, @storyblok/management-api-client

Bug Description

The types of the multi-value filter_query operators (in_array, all_in_array, and any_in_array once #965 lands) accept Array<string> | string. An array type-checks, but the client sends it as repeated keys (…[in_array]=red&…[in_array]=blue). The Content Delivery API reads these operators as a single comma-separated string and keeps only the last repeated key, so the filter silently uses the last value only. No error is raised.

The filter query docs only describe the comma-separated form: "Separate the values by a comma to filter by multiple values."

@storyblok/management-api-client uses the same query serializer. Its types only accept string for these operators, so it is only affected when an array is passed with a cast.

Steps to Reproduce

  1. In a space, create four stories with a string-array field colors: a ["red"], b ["blue"], c ["red", "blue"], d ["green"].
  2. Query them with the array form and the string form:
import { createApiClient } from "@storyblok/api-client";

const client = createApiClient({ accessToken: "<preview token>" });

// Returns b, c
await client.stories.list({
  query: { version: "draft", filter_query: { colors: { in_array: ["red", "blue"] } } },
});

// Returns a, b, c
await client.stories.list({
  query: { version: "draft", filter_query: { colors: { in_array: "red,blue" } } },
});

Reproduction URL

No response

Expected Behavior

Either the array form returns the same stories as the comma-separated string, or the types reject an array.

Actual Behavior

The array form filters on its last value only. Filtering on red and blue against the Content Delivery API:

How the values are sent any_in_array in_array all_in_array
=red,blue a, b, c ✅ a, b, c ✅ c ✅
=red&…=blue (what the client sends) b, c ❌ b, c ❌ b, c ❌
[]=red&…[]=blue 400: must be a string of comma separated values same same

Environment

Node: 24.18.0
@storyblok/api-client: 0.14.0
@storyblok/management-api-client: 0.14.0

Error Logs

None. The request succeeds and returns the wrong stories.

Additional Context

Activity

  1. added
    pkg: api-client
    type: bug
    on Nov 25, 2026
  2. self-assigned this
    on Nov 25, 2026
  3. added a commit that references this issue on Nov 25, 2026
    81de431
  4. changed the title [-][Bug]: array values in filter_query silently filter on the last value only[/-] [+]Blocked:[Bug]: array values in filter_query silently filter on the last value only[/+] on Nov 27, 2026
  5. changed the title [-]Blocked:[Bug]: array values in filter_query silently filter on the last value only[/-] [+][Bug]: array values in filter_query silently filter on the last value only[/+] on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

pkg: api-clienttype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0