jackwener / jackwener/OpenCLI

[Bug]: Xiaohongshu search fails with ambiguous_option on duplicated overlapping filter options

Open
#2,445 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
29.3k
Forks
2.9k
Avg merge
15h 36m
Merged PRs (30d)
70

Description

### Description

In OpenCLI v1.8.8, `opencli xiaohongshu search` can fail before result extraction with `ambiguous_option` on an affected Xiaohongshu search-page render.

The current `findOption()` implementation expects exactly one visible `.tag-container > .tags` element for each requested option. In the observed page, Xiaohongshu generated two overlapping elements for the same visible `综合` filter option. Both had the same active state and identical position and size, so a user still saw one option, but OpenCLI treated `options.length === 2` as an ambiguous layout and stopped the command.

This code path also runs when no filter flags are supplied because `resolveSearchFilters()` currently includes the default value for all five filter groups.

### Steps to Reproduce

1. Use an existing logged-in Xiaohongshu browser session.
2. Run:

```bash
opencli xiaohongshu search "OpenAI" --limit 2 -f json \
--window background --site-session ephemeral --keep-tab false
```

3. On a page render containing the duplicated overlapping option, the command exits before extracting results.

### Deterministic Reproduction

To remove dependence on live-page timing, I reproduced the same condition in a detached worktree at tag `v1.8.8`. I changed only the test fixture: it renders two visible `.tags active` nodes for `排序依据/综合`, each with the same text and the same rectangle (`left: 0`, `top: 0`, `width: 100`, `height: 100`), then runs a default search.

With the unmodified v1.8.8 production code, the regression test fails with:

```text
CommandExecutionError: Xiaohongshu search filter layout did not match the expected visible panel (ambiguous_option).
Tests 1 failed | 64 skipped (65)
```

With the local fix, the same test passes. The complete Xiaohongshu search test file also passes (`65/65`), including the existing fail-closed case where the second matching option is at a different position.

### Expected Behavior

Multiple page elements that represent the same visible filter option—with the same text, active state, position, and size—should be handled as one logical option.

Matches at different positions or with different active states should continue to fail closed as genuinely ambiguous.

### OpenCLI Version

1.8.8

### Node.js Version

Other — v24.19.0

### Operating System

macOS

### Logs / Screenshots

```shell
ok: false
error:
code: COMMAND_EXEC
message: Xiaohongshu search filter layout did not match the expected visible panel (ambiguous_option).
exitCode: 1
```

Diagnostic inspection found two matching `综合` elements with the same `tags active` state and identical bounding rectangles. No cookies, tokens, or account-specific data are included here.

### Related Work

The filter handling was introduced by #2276, which completed #903.

I have a small local fix and regression test that treat only overlapping matches with the same active state as one logical option, while preserving the existing failure for genuinely distinct matches. With that change, both the default search and `--sort latest` succeed against the same logged-in session. The full local test suite passes: 631 files, 7317 tests, 1 skipped.

Contributor guide

Open the contributing guide

Research direction

Start with findOption() and resolveSearchFilters(), then run the deterministic Xiaohongshu search regression test using the duplicated overlapping fixture described in the issue. Verify that identical text, active state, and geometry are treated as one logical option, while different positions or active states still fail closed; the complete Xiaohongshu search tests should pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.