Skip to content

Honor field encodings in FT.PROFILE search results - #4475

Merged
petyaslavova merged 2 commits into
redis:masterfrom
JackyHsu-X:JackyHsu-X/profile-field-encodings
Oct 22, 2026
Merged

petyaslavova merged 2 commits into
redis:masterfrom
JackyHsu-X:JackyHsu-X/profile-field-encodings

Conversation

@JackyHsu-X

@JackyHsu-X JackyHsu-X commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description of change

With decode_responses=False, FT.PROFILE ignores Query.return_field() encoding settings even though FT.SEARCH honors them. For example, .return_field("vector", decode_field=False) returns a string instead of the original bytes, dropping invalid UTF-8 bytes on the RESP2 path. A field configured with encoding="latin-1" is also decoded incorrectly.

Pass the query's field encoding map to the existing result constructors in the RESP2 legacy/unified and RESP3 profile parsers. The regression uses a binary field returned under an alias, a Latin-1 field and an ordinary text field across the default/explicit protocol and response modes, LIMITED, and scores. Public signatures and the explicit RESP3 legacy native profile shape are unchanged. The docstring clarifies that binary fields require decode_responses=False; this does not change transport-level decoding or add an async profile() API.

Validation against Redis 8.2.2 / Search 8.2.5 on Windows:

  • New live-server regression: 20 failed on the original implementation; 20 passed with the fix (Python 3.12.8).
  • Complete sync/async Search test modules: 238 passed, 121 skipped, 3 xpassed (Python 3.14.3, UTF-8 mode; dedicated server with debug commands enabled).
  • Full repository Ruff lint/format checks (273 files) and Vulture pass; git diff --check passes.
  • The full repository test run is blocked during collection by the unchanged tests/test_multiprocessing.py calling the unavailable Windows fork context. Linux, cluster, Enterprise and the full hosted CI matrix have not been run locally.

No existing issue or open PR was found for this profile-parser omission. #4025 introduced response unification and is already merged; this fixes the remaining field-encoding propagation in the profile result parsers.

AI assistance: OpenAI Codex investigated, implemented and ran the local checks, and drafted this description.

Pull Request check-list

  • Do tests and lints pass with this change? β€” Scoped suites and all linters pass; full-suite collection limitation is noted above.
  • Do the CI tests pass with this change? β€” Not yet run.
  • Is the new or changed code fully tested?
  • Is a documentation update included? β€” Updated profile() docstring; no API changes.
  • Is there an example added to the examples folder? β€” Not applicable.

Note

Low Risk
Parser-only alignment with existing FT.SEARCH behavior; no API or wire-format changes, with targeted regression coverage.

Overview
FT.PROFILE search result parsing now passes the query’s Query.return_field() encoding map into Result / Result.from_resp3, matching FT.SEARCH behavior. Binary fields (decode_field=False) and custom encodings (e.g. latin-1) are decoded correctly on RESP2 legacy/unified and RESP3 profile paths instead of being forced through default UTF-8 handling.

The profile() docstring notes that binary fields require decode_responses=False and return_field(..., decode_field=False). A live-server regression covers protocol, legacy_responses, LIMITED, and with_scores.

Reviewed by Cursor Bugbot for commit 77dda6a. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
πŸ“ Code Review βœ… Completed 2026-10-22T13:16:42.503525Z 1dcec91 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with πŸ‘€ while any review is running, comments if it has suggestions, and reacts with πŸ‘ once all reviews finish with no findings.

@petyaslavova petyaslavova left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JackyHsu-X, thank you for your contribution!

The fix matches how FT.SEARCH already passes the return_field encodings, and the live regression covers the relevant protocol and response modes. Looks good to me - I'll merge once CI passes.

@petyaslavova
petyaslavova merged commit 812fb06 into redis:master Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants