Skip to content

Harden web search context prop parsing - #929

Draft
cursor[bot] wants to merge 2 commits into
masterfrom
cursor/issue-resolution-workflow-9799
Draft

Harden web search context prop parsing#929
cursor[bot] wants to merge 2 commits into
masterfrom
cursor/issue-resolution-workflow-9799

Conversation

@cursor

@cursor cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Hardens how the Agents plugin parses the web_search_context post prop. Certain unexpected prop values could produce an uninitialized parse result that was then written to, causing the message-handling path to stop responding. The parser now normalizes such values before use, so message handling stays robust regardless of the prop contents.

Added a table-driven regression test in conversations/web_search_context_test.go covering the previously problematic input alongside the valid and malformed-input paths.

Ticket Link

Jira https://mattermost.atlassian.net/browse/MM-69942

Release Note

Fixed an edge case in the Agents plugin where certain web search context post properties could interrupt message handling.
Open in Web View Automation 

Summary by CodeRabbit

  • Bug Fixes

    • Improved web search context handling when input is empty, null, or missing.
    • Prevented potential errors during subsequent search tracking and context reconstruction.
    • Ensured search counts and executed-query tracking are reset consistently.
  • Tests

    • Added coverage for valid, empty, and malformed web search context data.

cursoragent and others added 2 commits July 27, 2026 11:46
Co-authored-by: mattermost-code <matty-code@mattermost.com>
Co-authored-by: mattermost-code <matty-code@mattermost.com>
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 74e63501-2ad6-432b-9a52-e1a3a8567c1d

📥 Commits

Reviewing files that changed from the base of the PR and between aaa3e4f and 81b428f.

📒 Files selected for processing (2)
  • conversations/web_search_context.go
  • conversations/web_search_context_test.go

📝 Walkthrough

Walkthrough

unmarshalWebSearchContext now initializes nil parameter maps before writing reconstructed search context values. Table-driven tests cover null, valid JSON objects, and malformed JSON inputs.

Changes

Web search context handling

Layer / File(s) Summary
Nil-map guard and regression coverage
conversations/web_search_context.go, conversations/web_search_context_test.go
Initializes nil parameter maps before tracking-key writes and tests reset tracking keys for null and valid inputs, while malformed JSON returns nil.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: Setup Cloud Test Server

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: hardening web search context prop parsing against nil-map edge cases.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/issue-resolution-workflow-9799

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🤖 LLM Evaluation Results

OpenAI

⚠️ Overall: 22/28 tests passed (78.6%)

Provider Total Passed Failed Pass Rate
⚠️ OPENAI 28 22 6 78.6%

❌ Failed Evaluations

Show 6 failures

OPENAI

1. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: is a list of bugs
  • Reason: The output does not provide an actual list of bugs; it states it cannot access the bug tracker and offers a template/table to fill in later.

2. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: includes a description of each bug
  • Reason: The output does not describe any specific bugs; it states it cannot access the bug tracker and provides an empty template to be filled in later. Therefore it does not include a description of each bug.

3. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: attributes each bug to a user
  • Reason: The output provides an empty template and asks the user to paste bug data; it does not actually attribute any specific bugs to any users.

4. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: attributes the bug about trying to save without a color and the save button not doing anything to @maria.nunez
  • Reason: The output does not mention the specific bug about saving without a color or the save button doing nothing, nor does it attribute any bug to @maria.nunez. It only provides a generic template and asks for bug data.

5. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: the bug about the end user being able to change channel banner is attributed to @maria.nunez
  • Reason: The output provides a generic template and does not list any specific bug, nor does it attribute a bug about an end user being able to change the channel banner to @maria.nunez.

6. TestDirectMessageConversations/[openai]_bot_dm_tool_introspection

  • Score: 0.50
  • Rubric: mentions Github and refers to the documentation
  • Reason: The output refers to documentation (Mattermost docs link) but does not mention GitHub anywhere, so it does not satisfy the requirement to mention GitHub and refer to the documentation.

Anthropic

⚠️ Overall: 10/11 tests passed (90.9%)

Provider Total Passed Failed Pass Rate
⚠️ ANTHROPIC 11 10 1 90.9%

❌ Failed Evaluations

Show 1 failures

ANTHROPIC

1. TestReactEval/[anthropic]_react_cat_message

  • Score: 0.00
  • Rubric: The word/emoji is a cat emoji or a heart/love emoji
  • Reason: The output is the text string "heart_eyes_cat", not an actual cat emoji (e.g., 😺/🐱) or a heart/love emoji (e.g., ❤️/😍).

This comment was automatically generated by the eval CI pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant