Skip to content

fix(contacts): coerce numeric values to strings in text custom attribute filters - #15558

Draft
ar1vit0r wants to merge 1 commit into
chatwoot:developfrom
ar1vit0r:fix/15519-contacts-filter-numeric-text-attribute
Draft

fix(contacts): coerce numeric values to strings in text custom attribute filters#15558
ar1vit0r wants to merge 1 commit into
chatwoot:developfrom
ar1vit0r:fix/15519-contacts-filter-numeric-text-attribute

Conversation

@ar1vit0r

Copy link
Copy Markdown

Description

When a numeric JSON value (e.g. 12345678901) is sent for a text custom attribute, PostgreSQL receives an integer bind param for a ::text cast, causing a type mismatch → HTTP 500.

This affects both the contacts filter (POST /api/v1/accounts/{id}/contacts/filter) and the conversations filter (POST /api/v1/accounts/{id}/conversations/filter).

Closes #15519

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Added 2 new specs in spec/services/contacts/filter_service_spec.rb:
    • equal_to filter with integer value on text custom attribute
    • contains filter with integer value on text custom attribute
  • All 27 specs in the filter service spec pass

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

…ute filters

When a numeric JSON value (e.g. 12345678901) was sent for a text custom
attribute, PostgreSQL received an integer bind param for a ::text cast,
causing a type mismatch 500.

- Add coerce_text_attribute_values to FilterService for text attrs
- Override filter_operation in Contacts::Conversations FilterService
- Fix values_for_ilike to call .to_s before .strip (contains path)

Closes chatwoot#15519
@ar1vit0r
ar1vit0r force-pushed the fix/15519-contacts-filter-numeric-text-attribute branch from ac3d05c to acb326b Compare August 21, 2026 22:30
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.

Contacts filter returns 500 when a text custom attribute is filtered with a numeric JSON value; dashboard silently shows unfiltered list

1 participant