Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8392: feat(properties): support up to 200 select options (#9712)

Bohan Jiangfe23bd116149
diff --git a/e2e/fixtures.ts b/e2e/fixtures.ts
index ea3336b661..bfb7c4a191 100644
--- a/e2e/fixtures.ts
+++ b/e2e/fixtures.ts
@@ -201,17 +201,17 @@ export class TestApiClient {
}
/** Create a workspace custom property definition; archived on cleanup. */
- async createProperty(name: string, type = "text") {
+ async createProperty(name: string, type = "text", config?: { options: { name: string; color: string }[] }) {
const res = await this.authedFetch("/api/properties", {
method: "POST",
- body: JSON.stringify({ name, type }),
+ body: JSON.stringify({ name, type, config }),
});
if (!res.ok) {
throw new Error(`create property failed: ${res.status} ${await res.text()}`);
}
const property = await res.json();
this.createdPropertyIds.push(property.id);
- return property as { id: string; name: string };
+ return property as { id: string; name: string; config: { options?: { id: string; name: string; color: string }[] } };
}
async updateProject(id: string, updates: Record<string, unknown>) {
diff --git a/e2e/property-select-options.spec.ts b/e2e/property-select-options.spec.ts
new file mode 100644
index 0000000000..9bd276806a
--- /dev/null
+++ b/e2e/property-select-options.spec.ts
@@ -0,0 +1,68 @@
+import { expect, test } from "@playwright/test";
+import { TestApiClient } from "./fixtures";
+
+for (const type of ["select", "multi_select"] as const) {
+ test(`edits and selects from 200 ${type} options`, async ({ page }) => {
+ const api = new TestApiClient();
+ const suffix = Date.now().toString(36);
+ let workspaceCreated = false;
+ try {
+ await api.login(`select-options-${type}-${suffix}@multica.ai`, "Property owner");
+ const workspace = await api.ensureWorkspace("Select options", `options-${type === "select" ? "s" : "m"}-${suffix}`);
+ workspaceCreated = true;
+ await api.markUserOnboarded();
+ const property = await api.createProperty("Services", type, {
+ options: Array.from({ length: 200 }, (_, i) => ({ name: `Service ${i + 1}`, color: "#3b82f6" })),
+ });
+ const options = property.config.options!;
+ const issue = await api.createIssue("Choose a service", {
+ properties: { [property.id]: type === "select" ? options[0]!.id : [options[0]!.id] },
+ });
+ const token = api.getToken();
+ if (!token) throw new Error("Owner login did not return a token");
+ await page.addInitScript((value) => {
+ localStorage.setItem("multica_token", value);
+ localStorage.setItem("multica:chat:isOpen", "false");
+ }, token);
+ await page.setViewportSize({ width: 1280, height: 800 });
+ await page.goto(`/${workspace.slug}/settings?tab=properties`);
+ await page.getByRole("button", { name: "Actions for Services", exact: true }).click();
+ await page.getByRole("menuitem", { name: "Edit", exact: true }).click();
+ const dialog = page.getByRole("dialog", { name: "Edit property" });
+ await expect(dialog.getByPlaceholder("Option name")).toHaveCount(200);
+ await expect(dialog.getByRole("button", { name: "Add option", exact: true })).toBeDisabled();
+ await dialog.getByPlaceholder("Option name").last().fill("Service 200 updated");
+ await expect(dialog.getByRole("button", { name: "Save property" })).toBeInViewport();
+ const editorImage = test.info().outputPath(`${type}-editor.png`);
+ await page.screenshot({ path: editorImage });
+ await test.info().attach("200-option editor", { path: editorImage, contentType: "image/png" });
+ const updated = page.waitForResponse((response) =>
+ response.url().endsWith(`/api/properties/${property.id}`) && response.request().method() === "PATCH",
+ );
+ await dialog.getByRole("button", { name: "Save property" }).click();
+ expect((await updated).ok()).toBe(true);
+ await expect(dialog).not.toBeVisible();
+
+ await page.goto(`/${workspace.slug}/issues/${issue.identifier}`);
+ await page.locator("[data-right-sidebar-panel]").getByRole("button", { name: "Service 1", exact: true }).click();
+ const search = page.getByRole("textbox", { name: "Filter options" });
+ await search.fill("service 200");
+ await expect(page.getByRole("button", { name: "Service 200 updated", exact: true })).toBeVisible();
+ await expect(page.locator("button[data-picker-item]").filter({ hasText: /^Service 1$/ })).toHaveCount(0);
+ const searchImage = test.info().outputPath(`${type}-search.png`);
+ await page.screenshot({ path: searchImage });
+ await test.info().attach("Search last option", { path: searchImage, contentType: "image/png" });
+ const saved = page.waitForResponse((response) =>
+ response.url().endsWith(`/api/issues/${issue.id}/properties/${property.id}`)
+ && response.request().method() === "PUT",
+ );
+ await search.press("Enter");
+ expect((await saved).ok()).toBe(true);
+ await page.reload();
+ await expect(page.locator("[data-right-sidebar-panel]").getByText("Service 200 updated", { exact: true })).toBeVisible();
+ } finally {
+ await api.cleanup();
+ if (workspaceCreated) await api.deleteWorkspace();
+ }
+ });
+}
diff --git a/packages/core/types/index.ts b/packages/core/types/index.ts
index ef70ded997..faa956c9c2 100644
--- a/packages/core/types/index.ts
+++ b/packages/core/types/index.ts
@@ -139,7 +139,7 @@ export type { NotificationGroupKey, NotificationGroupValue, NotificationPreferen
export type { Comment, CommentType, CommentAuthorType, CommentSupplementReceipt, CommentSupplementStatus, CommentTriggerPreview, CommentTriggerPreviewAgent, CommentTriggerSource, CommentTriggerOutcome, CommentTriggerStatus, Reaction } from "./comment";
export type { Label, LabelResourceType, CreateLabelRequest, UpdateLabelRequest, ListLabelsResponse, IssueLabelsResponse, ResourceLabelsResponse } from "./label";
export type { IssueProperty, IssuePropertyType, ScalarIssuePropertyType, ListIssuePropertyType, IssuePropertyOption, IssuePropertyConfig, IssuePropertyValue, IssuePropertyValues, CreatePropertyRequest, UpdatePropertyRequest, ListPropertiesResponse, IssuePropertiesResponse, IssuePropertyActorKind, IssuePropertyActorRef, PropertyFilterOp, PropertyOperatorFilter, PropertyFilterValue } from "./property";
-export { ISSUE_PROPERTY_TYPES, isKnownPropertyType, ISSUE_PROPERTY_ACTOR_KINDS, MAX_ISSUE_PROPERTY_ACTOR_VALUES, isActorPropertyType, isFilterablePropertyType, isScalarPropertyType, isListPropertyType, formatActorRef, parseActorRef, actorRefsFromValue, actorRefValuesFromValue, hasUnknownActorRef, isPropertyOperatorFilter, isKnownPropertyFilterOp, propertyFilterValueKey, PROPERTY_FILTER_OP_SYMBOLS, PROPERTY_FILTER_OPS_BY_TYPE } from "./property";
+export { ISSUE_PROPERTY_TYPES, isKnownPropertyType, ISSUE_PROPERTY_ACTOR_KINDS, MAX_ISSUE_PROPERTY_ACTOR_VALUES, MAX_ISSUE_PROPERTY_SELECT_VALUES, MAX_ISSUE_PROPERTY_SELECT_OPTIONS, MAX_ISSUE_PROPERTY_FILTER_VALUES, isActorPropertyType, isFilterablePropertyType, isScalarPropertyType, isListPropertyType, formatActorRef, parseActorRef, actorRefsFromValue, actorRefValuesFromValue, hasUnknownActorRef, isPropertyOperatorFilter, isKnownPropertyFilterOp, propertyFilterValueKey, PROPERTY_FILTER_OP_SYMBOLS, PROPERTY_FILTER_OPS_BY_TYPE } from "./property";
export type {
QuickAction,
QuickActionVisibility,
diff --git a/packages/core/types/property.ts b/packages/core/types/property.ts
index 22b7e7c4dd..ba8e580cf6 100644
--- a/packages/core/types/property.ts
+++ b/packages/core/types/property.ts
@@ -57,6 +57,15 @@ export const ISSUE_PROPERTY_ACTOR_KINDS: IssuePropertyActorKind[] = ["member"];
/** Upper bound on a single multi_actor value; mirrors the server cap. */
export const MAX_ISSUE_PROPERTY_ACTOR_VALUES = 20;
+/** Upper bound on a single multi_select value; mirrors the server cap. */
+export const MAX_ISSUE_PROPERTY_SELECT_VALUES = 50;
+
+/** Upper bound on a select / multi_select definition; mirrors the server cap. */
+export const MAX_ISSUE_PROPERTY_SELECT_OPTIONS = 200;
+
+/** Per-property filter budget, including No value; mirrors the server cap. */
+export const MAX_ISSUE_PROPERTY_FILTER_VALUES = 50;
+
export interface IssuePropertyActorRef {
kind: IssuePropertyActorKind;
/** Members are referenced by `user_id`, matching the issue assignee pair. */
diff --git a/packages/views/issues/components/issues-header.property-filter.test.tsx b/packages/views/issues/components/issues-header.property-filter.test.tsx
index 31c407e81d..f6e0adc256 100644
--- a/packages/views/issues/components/issues-header.property-filter.test.tsx
+++ b/packages/views/issues/components/issues-header.property-filter.test.tsx
@@ -44,7 +44,7 @@ function textProperty(id: string, name: string): IssueProperty {
};
}
-function renderFilterMenu(props: IssueProperty[]) {
+function renderFilterMenu(props: IssueProperty[], propertyFilters: IssueViewState["propertyFilters"] = {}) {
setApiInstance({
listIssueStatuses: async () => ({ statuses: [], categories: [], total: 0 }),
listProperties: async () => ({ properties: props }),
@@ -67,6 +67,7 @@ function renderFilterMenu(props: IssueProperty[]) {
defaultOptions: { queries: { retry: false, staleTime: Infinity } },
});
const store = createStore<IssueViewState>()(viewStoreSlice);
+ store.setState({ propertyFilters });
const view = renderWithI18n(
<QueryClientProvider client={qc}>
@@ -95,6 +96,45 @@ afterEach(() => {
vi.restoreAllMocks();
});
+describe("IssueFilterMenu select property filter", () => {
+ it.each(["select", "multi_select"])("caps %s filters at 50 including No value and permits replacement", async (type) => {
+ const property = {
+ ...textProperty("prop-services", "Services"), type,
+ config: {
+ options: Array.from({ length: 51 }, (_, i) => ({
+ id: `option-${i + 1}`, name: `Service ${i + 1}`, color: "#3b82f6",
+ })),
+ },
+ };
+ const selected = property.config.options.slice(0, 50).map((option) => option.id);
+ const { store } = renderFilterMenu([property], { [property.id]: selected });
+ fireEvent.click(screen.getByRole("button", { name: "Filter" }));
+ fireEvent.click(await screen.findByRole("menuitem", { name: /Services/ }));
+ const extra = await screen.findByRole("menuitemcheckbox", { name: "Service 51" });
+ const noValue = screen.getByRole("menuitemcheckbox", { name: "No value" });
+ expect(extra).toHaveAttribute("aria-disabled", "true");
+ expect(noValue).toHaveAttribute("aria-disabled", "true");
+ fireEvent.click(extra);
+ fireEvent.click(noValue);
+ expect(store.getState().propertyFilters[property.id]).toEqual(selected);
+
+ const lastSelected = screen.getByRole("menuitemcheckbox", { name: "Service 50" });
+ expect(lastSelected).not.toHaveAttribute("aria-disabled", "true");
+ fireEvent.click(lastSelected);
+ expect(noValue).not.toHaveAttribute("aria-disabled", "true");
+ fireEvent.click(noValue);
+ expect(store.getState().propertyFilters[property.id]).toEqual([...selected.slice(0, 49), "__none__"]);
+ expect(extra).toHaveAttribute("aria-disabled", "true");
+ expect(noValue).not.toHaveAttribute("aria-disabled", "true");
+
+ fireEvent.click(noValue);
+ expect(extra).not.toHaveAttribute("aria-disabled", "true");
+ fireEvent.click(extra);
+ expect(store.getState().propertyFilters[property.id]).toEqual([...selected.slice(0, 49), "option-51"]);
+ expect(lastSelected).toHaveAttribute("aria-disabled", "true");
+ });
+});
+
describe("IssueFilterMenu scalar property filter", () => {
const PROP = "prop-note";
diff --git a/packages/views/issues/components/issues-header.tsx b/packages/views/issues/components/issues-header.tsx
index 04532787ff..7f27d23844 100644
--- a/packages/views/issues/components/issues-header.tsx
+++ b/packages/views/issues/components/issues-header.tsx
@@ -76,7 +76,7 @@ import type {
ProjectStatus,
WorkingAgentSummary,
} from "@multica/core/types";
-import { formatActorRef, isActorPropertyType, isFilterablePropertyType, isListPropertyType, isScalarPropertyType, propertyFilterValueKey, PROPERTY_FILTER_OP_SYMBOLS, PROPERTY_FILTER_OPS_BY_TYPE, type PropertyFilterOp, type PropertyFilterValue } from "@multica/core/types";
+import { formatActorRef, isActorPropertyType, isFilterablePropertyType, isListPropertyType, isScalarPropertyType, propertyFilterValueKey, MAX_ISSUE_PROPERTY_FILTER_VALUES, PROPERTY_FILTER_OP_SYMBOLS, PROPERTY_FILTER_OPS_BY_TYPE, type PropertyFilterOp, type PropertyFilterValue } from "@multica/core/types";
import { ProjectIcon } from "../../projects/components/project-icon";
import { useProjectStatusLabels } from "../../projects/components/labels";
import { ActorAvatar } from "../../common/actor-avatar";
@@ -992,6 +992,7 @@ function PropertyFilterOptions({
);
}
+ const atCapacity = selected.length >= MAX_ISSUE_PROPERTY_FILTER_VALUES;
return (
<>
{options.map((option) => {
@@ -1001,7 +1002,7 @@ function PropertyFilterOptions({
<DropdownMenuCheckboxItem
key={option.id}
checked={checked}
- disabled={fixedIds?.has(option.id) === true}
+ disabled={fixedIds?.has(option.id) === true || (atCapacity && !checked)}
title={fixedIds?.has(option.id) === true ? fixedTitle : undefined}
onCheckedChange={() => onToggle(option.id)}
className={FILTER_ITEM_CLASS}
diff --git a/packages/views/issues/components/pickers/custom-property-picker.select.test.tsx b/packages/views/issues/components/pickers/custom-property-picker.select.test.tsx
new file mode 100644
index 0000000000..ae1ebf7b32
--- /dev/null
+++ b/packages/views/issues/components/pickers/custom-property-picker.select.test.tsx
@@ -0,0 +1,82 @@
+import { useState } from "react";
+import { render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { describe, expect, it, vi } from "vitest";
+import { I18nProvider } from "@multica/core/i18n/react";
+import type { IssueProperty, IssuePropertyValue } from "@multica/core/types";
+import enIssues from "../../../locales/en/issues.json";
+import { CustomPropertyValueInput } from "./custom-property-picker";
+
+const options = Array.from({ length: 51 }, (_, i) => ({
+ id: `option-${i + 1}`, name: `Service ${i + 1}`, color: "#3b82f6",
+}));
+const property: IssueProperty = {
+ id: "p-1", workspace_id: "ws-1", name: "Services", type: "multi_select",
+ config: { options }, position: 1, archived: false,
+ created_at: "2026-01-01T00:00:00Z", updated_at: "2026-01-01T00:00:00Z",
+};
+
+// Eight options is the smallest searchable list; browser tests cover 200 options.
+function renderPicker(count: number, type: "select" | "multi_select" = "multi_select", optionCount = 8) {
+ const onChange = vi.fn();
+ function Picker() {
+ const [value, setValue] = useState<IssuePropertyValue | undefined>(
+ type === "multi_select" ? options.slice(0, count).map((option) => option.id) : undefined,
+ );
+ return (
+ <I18nProvider locale="en" resources={{ en: { issues: enIssues } }}>
+ <CustomPropertyValueInput
+ property={{ ...property, type, config: { options: options.slice(0, optionCount) } }} value={value} defaultOpen trigger="Services"
+ onChange={(next) => { onChange(next); setValue(next); }}
+ />
+ </I18nProvider>
+ );
+ }
+ render(<Picker />);
+ return onChange;
+}
+
+describe("select property picker", () => {
+ it("caps multi-select values at 50 while allowing removal and replacement", async () => {
+ const user = userEvent.setup();
+ const onChange = renderPicker(50, "multi_select", 51);
+ const last = await screen.findByRole("button", { name: "Service 51" });
+ expect(last).toBeDisabled();
+ await user.click(last);
+ expect(onChange).not.toHaveBeenCalled();
+
+ await user.click(screen.getByRole("button", { name: "Service 50" }));
+ expect(last).toBeEnabled();
+ await user.click(last);
+ expect(onChange).toHaveBeenLastCalledWith([
+ ...options.slice(0, 49).map((option) => option.id), "option-51",
+ ]);
+ expect(screen.getByRole("button", { name: "Service 50" })).toBeDisabled();
+ expect(last).toBeEnabled();
+ });
+
+ it.each(["select", "multi_select"] as const)("searches and selects the last %s option with the keyboard", async (type) => {
+ const user = userEvent.setup();
+ const onChange = renderPicker(0, type);
+ const search = await screen.findByRole("textbox");
+ await user.type(search, "SERVICE 8{Enter}");
+ expect(onChange).toHaveBeenLastCalledWith(type === "select" ? "option-8" : ["option-8"]);
+ });
+
+ it("does not clear the value when a search has no matches", async () => {
+ const user = userEvent.setup();
+ const onChange = renderPicker(1);
+ await user.type(await screen.findByRole("textbox"), "no such service{Enter}");
+ expect(screen.queryByRole("button", { name: "Service 1" })).not.toBeInTheDocument();
+ expect(onChange).not.toHaveBeenCalled();
+ });
+
+ it("resets the search when reopened after selection", async () => {
+ const user = userEvent.setup();
+ renderPicker(0, "select");
+ await user.type(await screen.findByRole("textbox"), "Service 8{Enter}");
+ await user.click(screen.getByRole("button", { name: "Services" }));
+ expect(await screen.findByRole("textbox")).toHaveValue("");
+ expect(screen.getByRole("button", { name: "Service 1" })).toBeInTheDocument();
+ });
+});
diff --git a/packages/views/issues/components/pickers/custom-property-picker.tsx b/packages/views/issues/components/pickers/custom-property-picker.tsx
index b029fb70d0..b1359e259f 100644
--- a/packages/views/issues/components/pickers/custom-property-picker.tsx
+++ b/packages/views/issues/components/pickers/custom-property-picker.tsx
@@ -4,7 +4,7 @@ import { useEffect, useId, useRef, useState } from "react";
import { CalendarDays, Check, ExternalLink, X } from "@multica/ui/icons";
import { toast } from "sonner";
import type { Issue, IssueProperty, IssuePropertyValue } from "@multica/core/types";
-import { hasUnknownActorRef, isListPropertyType } from "@multica/core/types";
+import { hasUnknownActorRef, isListPropertyType, MAX_ISSUE_PROPERTY_SELECT_VALUES } from "@multica/core/types";
import {
useSetIssueProperty,
useUnsetIssueProperty,
@@ -23,7 +23,8 @@ import {
import { IconButton } from "@multica/ui/components/common/icon-button";
import { Input } from "@multica/ui/components/ui/input";
import { useLocale, useT } from "../../../i18n";
-import { PropertyPicker, PickerItem } from "./property-picker";
+import { matchesPinyin } from "../../../editor/extensions/pinyin-match";
+import { PropertyPicker, PickerItem, PickerEmpty } from "./property-picker";
import { ActorPropertyPicker, ActorPropertyDisplay } from "./actor-property-picker";
const EDITABLE_PROPERTY_TYPES = [
@@ -156,9 +157,15 @@ export function CustomPropertyValueInput({
}) {
const { t } = useT("issues");
const [internalOpen, setInternalOpen] = useState(defaultOpen);
+ const [optionSearch, setOptionSearch] = useState("");
const open = controlledOpen ?? internalOpen;
const setOpen = controlledOnOpenChange ?? setInternalOpen;
const hasValue = value !== undefined;
+ const options = property.config.options ?? [];
+ const optionQuery = optionSearch.trim().toLowerCase();
+ const filteredOptions = options.filter((option) =>
+ option.name.toLowerCase().includes(optionQuery) || matchesPinyin(option.name, optionQuery),
+ );
const commit = (next: IssuePropertyValue) => onChange(next);
const clear = () => onChange(undefined);
@@ -211,18 +218,18 @@ export function CustomPropertyValueInput({
switch (property.type) {
case "select": {
- const options = property.config.options ?? [];
return (
<PropertyPicker
open={open}
onOpenChange={setOpen}
align="start"
searchable={options.length > 7}
+ onSearchChange={setOptionSearch}
trigger={valueTrigger}
triggerRender={triggerRender}
>
{emptyRow}
- {options.map((option) => (
+ {filteredOptions.map((option) => (
<PickerItem
key={option.id}
selected={value === option.id}
@@ -235,12 +242,13 @@ export function CustomPropertyValueInput({
<span className="truncate">{option.name}</span>
</PickerItem>
))}
+ {filteredOptions.length === 0 && <PickerEmpty />}
</PropertyPicker>
);
}
case "multi_select": {
- const options = property.config.options ?? [];
const selected = Array.isArray(value) ? value : [];
+ const atCapacity = selected.length >= MAX_ISSUE_PROPERTY_SELECT_VALUES;
const toggle = (optionId: string) => {
const next = selected.includes(optionId)
? selected.filter((id) => id !== optionId)
@@ -254,20 +262,23 @@ export function CustomPropertyValueInput({
onOpenChange={setOpen}
align="start"
searchable={options.length > 7}
+ onSearchChange={setOptionSearch}
trigger={valueTrigger}
triggerRender={triggerRender}
>
{emptyRow}
- {options.map((option) => (
+ {filteredOptions.map((option) => (
<PickerItem
key={option.id}
selected={selected.includes(option.id)}
+ disabled={atCapacity && !selected.includes(option.id)}
onClick={() => toggle(option.id)}
>
<span className="size-2.5 shrink-0 rounded-full" style={{ backgroundColor: option.color }} />
<span className="truncate">{option.name}</span>
</PickerItem>
))}
+ {filteredOptions.length === 0 && <PickerEmpty />}
</PropertyPicker>
);
}
diff --git a/packages/views/settings/components/properties-tab.tsx b/packages/views/settings/components/properties-tab.tsx
index b1d3c2bb4d..1136877c1b 100644
--- a/packages/views/settings/components/properties-tab.tsx
+++ b/packages/views/settings/components/properties-tab.tsx
@@ -27,7 +27,7 @@ import type {
IssuePropertyOption,
IssuePropertyType,
} from "@multica/core/types";
-import { ISSUE_PROPERTY_TYPES } from "@multica/core/types";
+import { ISSUE_PROPERTY_TYPES, MAX_ISSUE_PROPERTY_SELECT_OPTIONS } from "@multica/core/types";
import { Button } from "@multica/ui/components/ui/button";
import { IconButton } from "@multica/ui/components/common/icon-button";
import { Badge } from "@multica/ui/components/ui/badge";
@@ -627,6 +627,7 @@ function PropertyEditorDialog({
variant="ghost"
size="sm"
className="gap-2"
+ disabled={draft.options.length >= MAX_ISSUE_PROPERTY_SELECT_OPTIONS}
onClick={() =>
setDraft((current) => ({
...current,
diff --git a/server/internal/handler/property.go b/server/internal/handler/property.go
index 8910780caf..3b89204d8e 100644
--- a/server/internal/handler/property.go
+++ b/server/internal/handler/property.go
@@ -40,7 +40,7 @@ import (
// values but keep existing ones resolvable.
const (
maxActivePropertiesPerWorkspace = 20
- maxPropertySelectOptions = 50
+ maxPropertySelectOptions = 200
maxPropertyNameLen = 32
maxPropertyIconLen = 32
maxPropertyDescriptionLen = 500
@@ -234,7 +234,7 @@ func propertyTypeHasOptions(t string) bool {
}
// validatePropertyConfig canonicalizes the config for storage. Select-type
-// properties require 1..50 options; each option gets a stable server-assigned
+// properties require 1..200 options; each option gets a stable server-assigned
// UUID if the caller didn't provide one (values reference option IDs, so
// option renames never touch issue rows). Non-select types must not carry
// options and are stored as {}.
diff --git a/server/internal/handler/property_test.go b/server/internal/handler/property_test.go
index 137b2383cc..3d65229236 100644
--- a/server/internal/handler/property_test.go
+++ b/server/internal/handler/property_test.go
@@ -219,6 +219,114 @@ func TestPropertyDefinitionValidation(t *testing.T) {
}
}
+func TestPropertySelectOptionLimit(t *testing.T) {
+ for _, propertyType := range []string{"select", "multi_select"} {
+ t.Run(propertyType, func(t *testing.T) {
+ options := make([]PropertyOption, 201)
+ for i := range options {
+ options[i] = PropertyOption{Name: fmt.Sprintf("Service %03d", i), Color: "#3b82f6"}
+ }
+ body := map[string]any{
+ "name": "Services" + uuid.NewString()[:8], "type": propertyType,
+ "config": PropertyConfig{Options: options[:51]},
+ }
+ created := createTestProperty(t, body)
+ if len(created.Config.Options) != 51 {
+ t.Fatalf("created option count = %d, want 51", len(created.Config.Options))
+ }
+ copy(options, created.Config.Options)
+ var updated PropertyResponse
+ testutil.Call(t, testHandler.UpdateProperty,
+ withURLParam(newRequest(http.MethodPatch, "/api/properties/"+created.ID, map[string]any{
+ "config": PropertyConfig{Options: options[:200]},
+ }), "id", created.ID),
+ ).Want(http.StatusOK).JSON(&updated)
+ if len(updated.Config.Options) != 200 || updated.Config.Options[0].ID != created.Config.Options[0].ID {
+ t.Fatalf("expanding to 200 did not preserve options: %+v", updated.Config)
+ }
+
+ body["name"] = "OverLimit" + uuid.NewString()[:8]
+ body["config"] = PropertyConfig{Options: options}
+ response := testutil.Call(t, testHandler.CreateProperty,
+ newRequest(http.MethodPost, "/api/properties", body),
+ ).Want(http.StatusBadRequest)
+ if !strings.Contains(response.Body.String(), "more than 200 options") {
+ t.Fatalf("unexpected create limit error: %s", response.Body.String())
+ }
+ response = testutil.Call(t, testHandler.UpdateProperty,
+ withURLParam(newRequest(http.MethodPatch, "/api/properties/"+created.ID, map[string]any{
+ "config": PropertyConfig{Options: options},
+ }), "id", created.ID),
+ ).Want(http.StatusBadRequest)
+ if !strings.Contains(response.Body.String(), "more than 200 options") {
+ t.Fatalf("unexpected update limit error: %s", response.Body.String())
+ }
+
+ issueID := dbfx.Issue(t, "large select option list")
+ lastID := updated.Config.Options[199].ID
+ var value any = lastID
+ if propertyType == "multi_select" {
+ value = []string{lastID}
+ }
+ if response := setIssuePropertyRaw(t, issueID, created.ID, value); response.Code != http.StatusOK {
+ t.Fatalf("selecting option 200: %d: %s", response.Code, response.Body.String())
+ }
+ filter, _ := json.Marshal(map[string][]string{created.ID: {lastID}})
+ var listed struct {
+ Issues []IssueResponse `json:"issues"`
+ }
+ testutil.Call(t, testHandler.ListIssues,
+ newRequest(http.MethodGet, "/api/issues?properties="+url.QueryEscape(string(filter)), nil),
+ ).Want(http.StatusOK).JSON(&listed)
+ if len(listed.Issues) != 1 || listed.Issues[0].ID != issueID {
+ t.Fatalf("filtering by option 200 did not return the issue: %+v", listed.Issues)
+ }
+ })
+ }
+}
+
+func TestIssuePropertyMultiSelectValueLimit(t *testing.T) {
+ options := make([]PropertyOption, 200)
+ for i := range options {
+ options[i] = PropertyOption{Name: fmt.Sprintf("Service %03d", i), Color: "#3b82f6"}
+ }
+ property := createTestProperty(t, map[string]any{
+ "name": "SelectionLimit" + uuid.NewString()[:8], "type": "multi_select",
+ "config": PropertyConfig{Options: options},
+ })
+ ids := make([]string, 51)
+ for i := range ids {
+ ids[i] = property.Config.Options[149+i].ID
+ }
+ title := "selection limit " + uuid.NewString()
+ body := map[string]any{"title": title, "properties": map[string]any{property.ID: ids}}
+ response := testutil.Call(t, testHandler.CreateIssue,
+ newRequest(http.MethodPost, "/api/issues", body),
+ ).Want(http.StatusBadRequest)
+ if !strings.Contains(response.Body.String(), "more than 50 options") || countIssuesWithAtomicPropertyTitle(t, title) != 0 {
+ t.Fatalf("over-limit create should fail atomically: %s", response.Body.String())
+ }
+ body["properties"] = map[string]any{property.ID: ids[:50]}
+ created := createIssueWithPropertyBody(t, body)
+ if values, ok := created.Properties[property.ID].([]any); !ok || len(values) != 50 {
+ t.Fatalf("50 selections not preserved on create: %#v", created.Properties)
+ }
+ if response := setIssuePropertyRaw(t, created.ID, property.ID, ids[:50]); response.Code != http.StatusOK {
+ t.Fatalf("50 selections rejected: %d: %s", response.Code, response.Body.String())
+ }
+ if response := setIssuePropertyRaw(t, created.ID, property.ID, ids); response.Code != http.StatusBadRequest || !strings.Contains(response.Body.String(), "more than 50 options") {
+ t.Fatalf("51 selections should fail: %d: %s", response.Code, response.Body.String())
+ }
+ var stored []byte
+ if err := testPool.QueryRow(context.Background(), `SELECT properties -> $2 FROM issue WHERE id = $1`, created.ID, property.ID).Scan(&stored); err != nil {
+ t.Fatal(err)
+ }
+ var values []string
+ if err := json.Unmarshal(stored, &values); err != nil || len(values) != 50 {
+ t.Fatalf("rejected write changed saved values: %s, %v", stored, err)
+ }
+}
+
// TestPropertyAdminGate verifies the two definition-management gates: agent
// actors are rejected outright (even though the fixture user is the workspace
// owner), while value writes from the same agent context succeed.
diff --git a/server/internal/issueproperty/value.go b/server/internal/issueproperty/value.go
index 42dc6d6af2..241b9bd965 100644
--- a/server/internal/issueproperty/value.go
+++ b/server/internal/issueproperty/value.go
@@ -22,6 +22,10 @@ import (
const (
maxTextValueLen = 2000
maxURLValueLen = 2048
+ // Keep per-issue selections at the former definition cap so larger
+ // vocabularies do not crowd out the shared 16KB properties bag.
+ maxMultiSelectValues = 50
+ maxOptionsHint = 20
// MaxActorValues is exported so the handler's existing focused tests can
// continue to pin the public multi-actor limit after validation moved here.
MaxActorValues = 20
@@ -157,9 +161,13 @@ func optionOrder(config propertyConfig) map[string]int {
}
func optionsHint(config propertyConfig) string {
- parts := make([]string, len(config.Options))
- for index, option := range config.Options {
- parts[index] = fmt.Sprintf("%s (%s)", option.ID, option.Name)
+ visible := config.Options[:min(len(config.Options), maxOptionsHint)]
+ parts := make([]string, 0, len(visible)+1)
+ for _, option := range visible {
+ parts = append(parts, fmt.Sprintf("%s (%s)", option.ID, option.Name))
+ }
+ if remaining := len(config.Options) - len(visible); remaining > 0 {
+ parts = append(parts, fmt.Sprintf("... (%d more options; retrieve the property definition for the full list)", remaining))
}
return strings.Join(parts, ", ")
}
@@ -310,6 +318,9 @@ func ValidateValue(def db.IssueProperty, raw json.RawMessage) ([]byte, error) {
}
seen[id] = struct{}{}
ids = append(ids, id)
+ if len(ids) > maxMultiSelectValues {
+ return nil, fmt.Errorf("value cannot list more than %d options", maxMultiSelectValues)
+ }
}
sort.SliceStable(ids, func(left, right int) bool { return order[ids[left]] < order[ids[right]] })
return json.Marshal(ids)
diff --git a/server/internal/issueproperty/value_test.go b/server/internal/issueproperty/value_test.go
new file mode 100644
index 0000000000..476399e6c5
--- /dev/null
+++ b/server/internal/issueproperty/value_test.go
@@ -0,0 +1,100 @@
+package issueproperty
+
+import (
+ "encoding/json"
+ "fmt"
+ "slices"
+ "strings"
+ "testing"
+
+ "github.com/google/uuid"
+ db "github.com/multica-ai/multica/server/pkg/db/generated"
+)
+
+func TestMultiSelectValueLimit(t *testing.T) {
+ options := make([]propertyOption, 200)
+ ids := make([]string, len(options))
+ for i := range options {
+ ids[i] = uuid.NewString()
+ options[i] = propertyOption{ID: ids[i], Name: fmt.Sprintf("Option %d", i)}
+ }
+ config, err := json.Marshal(propertyConfig{Options: options})
+ if err != nil {
+ t.Fatal(err)
+ }
+ def := db.IssueProperty{Type: "multi_select", Config: config}
+
+ for _, count := range []int{1, 50, 51, 200} {
+ t.Run(fmt.Sprintf("%d distinct values", count), func(t *testing.T) {
+ values := slices.Clone(ids[len(ids)-count:])
+ slices.Reverse(values)
+ raw, _ := json.Marshal(values)
+ stored, err := ValidateValue(def, raw)
+ if count > 50 {
+ if err == nil || !strings.Contains(err.Error(), "more than 50 options") {
+ t.Fatalf("expected selection limit error, got %s, %v", stored, err)
+ }
+ return
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ want, _ := json.Marshal(ids[len(ids)-count:])
+ if string(stored) != string(want) {
+ t.Fatalf("stored = %s, want config order %s", stored, want)
+ }
+ })
+ }
+
+ t.Run("duplicates retain existing canonicalization", func(t *testing.T) {
+ values := slices.Repeat(ids[:50], 4)
+ raw, _ := json.Marshal(values)
+ stored, err := ValidateValue(def, raw)
+ if err != nil {
+ t.Fatal(err)
+ }
+ want, _ := json.Marshal(ids[:50])
+ if string(stored) != string(want) {
+ t.Fatalf("stored = %s, want deduplicated %s", stored, want)
+ }
+ })
+}
+
+func TestSelectValueHintsAreBounded(t *testing.T) {
+ for _, count := range []int{1, 20, 21, 200} {
+ t.Run(fmt.Sprintf("%d options", count), func(t *testing.T) {
+ options := make([]propertyOption, count)
+ for i := range options {
+ options[i] = propertyOption{ID: uuid.NewString(), Name: fmt.Sprintf("Option %d", i)}
+ }
+ config, _ := json.Marshal(propertyConfig{Options: options})
+ for _, propertyType := range []string{"select", "multi_select"} {
+ def := db.IssueProperty{Type: propertyType, Config: config}
+ _, err := ValidateValue(def, json.RawMessage(`"unknown"`))
+ if err == nil {
+ t.Fatal("invalid selection accepted")
+ }
+ message := err.Error()
+ for _, option := range options[:min(count, 20)] {
+ if !strings.Contains(message, option.ID+" ("+option.Name+")") {
+ t.Fatalf("%s error missing option %s: %s", propertyType, option.ID, message)
+ }
+ }
+ if count > 20 {
+ if strings.Contains(message, options[20].ID) || !strings.Contains(message, fmt.Sprintf("%d more options", count-20)) {
+ t.Fatalf("%s error should truncate long lists: %s", propertyType, message)
+ }
+ }
+ last := options[count-1].ID
+ var value any = last
+ if propertyType == "multi_select" {
+ value = []string{last}
+ }
+ raw, _ := json.Marshal(value)
+ if _, err := ValidateValue(def, raw); err != nil {
+ t.Fatalf("%s rejected last valid option: %v", propertyType, err)
+ }
+ }
+ })
+ }
+}