Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 15, 2025

Problem

The doctest in doctests/query-em.js (test case em3) was incorrectly demonstrating how to search for email addresses in TAG fields. The test was wrapped in a try-catch block that printed "'[email protected]' syntax not yet supported", giving the false impression that searching TAG fields with special characters is unsupported functionality.

Root Cause

The original code attempted to search using:

const res6 = await client.ft.search('idx:email', '[email protected]', { DIALECT: 2 });

This fails because:

  1. Special characters like @ and . must be escaped when searching TAG field values
  2. The query syntax must explicitly specify the field: @fieldname:{value}

According to Redis documentation, punctuation characters in TAG fields require proper escaping.

Solution

Updated the test to use the correct pattern already demonstrated in examples/search-json.js:

// Escape special characters (. and @) in the email address for TAG field search
const emailAddress = '[email protected]'.replace(/[.@\\]/g, '\\$&');
const res6 = await client.ft.search('idx:email', `@email:{${emailAddress}}`);
console.log(res6.total); // >>> 1

Changes

  • Removed the misleading try-catch block
  • Added proper special character escaping for TAG field values
  • Used correct query syntax with field specifier
  • Added assertion to verify the search returns the expected result
  • Added explanatory comment about the escaping requirement

This converts a failing test that was hiding behind error handling into properly working documentation that demonstrates the correct usage pattern.

Original prompt

find an issue and lets see if you can fix it


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link

jit-ci bot commented Oct 15, 2025

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

Copilot AI and others added 2 commits October 15, 2025 15:35
- Remove incorrect try-catch block that hid the real issue
- Add proper escaping for special characters (@ and .) in email address
- Use correct search syntax: @email:{escaped_value}
- Add assertion to verify the search returns 1 result
- Add explanatory comment about escaping

Co-authored-by: nkaradzhov <[email protected]>
@Copilot Copilot AI changed the title [WIP] Fix identified issue in the codebase Fix TAG field search with special characters in doctest Oct 15, 2025
@Copilot Copilot AI requested a review from nkaradzhov October 15, 2025 15:43
Copilot finished work on behalf of nkaradzhov October 15, 2025 15:43
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.

2 participants