Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Can't filter for CONTAINS a numerical string #392

Open
pigrammer3 opened this issue Dec 17, 2024 · 1 comment
Open

[BUG] Can't filter for CONTAINS a numerical string #392

pigrammer3 opened this issue Dec 17, 2024 · 1 comment
Labels
bug Something isn't working server-side issue with Slack HTTP API

Comments

@pigrammer3
Copy link

The deno-slack versions

    "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.14.2/",
    "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.8.0/"

Deno runtime version

deno 1.46.3 (stable, release, x86_64-pc-windows-msvc)
v8 12.9.202.5-rusty
typescript 5.5.2

OS info

Microsoft Windows [Version 10.0.19045.5247]

Describe the bug

When creating an Event trigger, if I am filtering for messages that contain a digit string, some part of Slack interprets it as filtering for containing a number and it gives an error.

Steps to reproduce

  1. Suppose I am trying to filter for messages that contain a certain number, say 573. Pretend this is for a leaderboard; I want to see who sends the most messages containing the number 573.
  2. triggers/leaderboard_update.ts:
import { Trigger } from "deno-slack-sdk/types.ts";
import LeaderboardUpdateDefinition from "../functions/leaderboard_update/definition.ts";
import { TriggerContextData, TriggerEventTypes, TriggerTypes } from "deno-slack-api/mod.ts";

const LeaderboardUpdateTrigger: Trigger<
  typeof LeaderboardUpdateDefinition.definition
> = {
  type: TriggerTypes.Event,
  name: "leaderboard update",
  description: "Update the leaderboard for 573 messages",
  workflow: "#/workflows/leaderboard_update_workflow",
  event: {
    event_type: TriggerEventTypes.MessagePosted,
    channel_ids: ["C046CFN4AJ0"],
    filter: {
      version: 1,
      root: {
        operator: "OR",
        inputs: [
          { statement: "{{data.text}} CONTAINS '573'"},
          { statement: "{{data.text}} CONTAINS '5 73'"},
        ]
      }
    }
  },
  inputs: {
    user_id: {
      value: TriggerContextData.Event.MessagePosted.user_id,
    },
    timestamp: {
      value: TriggerContextData.Event.MessagePosted.message_ts,
    },
  }
};

export default LeaderboardUpdateTrigger;

(I have the option with a space there to demonstrate that if it is not a purely digit string, there is no error).
3. Send any message in that channel.

Expected result

The workflow should trigger if the message contains 573, and not trigger otherwise.

Actual result

From slack activity --tail:

2024-12-16 21:22:35 [error] [Wf085AP4AB3P] (Trace=Tr0862EGC5B2) Trigger for workflow 'Get 573 leaderboard' failed: Hermes\Types\IntegerValue is not supported by operator CONTAINS

Note that if I replace the CONTAINS operand '573' with, say, 'hello', there are no errors and it triggers fine.

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@zimeg zimeg added bug Something isn't working server-side issue with Slack HTTP API labels Dec 17, 2024
@zimeg
Copy link
Member

zimeg commented Dec 17, 2024

Hey @pigrammer3! 👋 🥧 Thanks for sending this in with setup steps! 👾

I can confirm that numbers aren't being cast to strings in the CONTAINS statement, causing the same error you're finding. This operator is documented as supporting just strings, but it makes sense to support numbers here.

Various other attempts at escaping the number brought no luck for me. Both the SDK and CLI are also passing the provided trigger details to the API as is - shown in --verbose outputs - so I'm marking this as a server-side issue and will share this with the backend team.

Unfortunately I'm unaware of a workaround for checking if numbers are contained for the event trigger, but similar logic can be implemented in a custom function in the meantime. I hope this is helpful for now, but I hope to share updates about some changes to this filtering logic soon 🙏 ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server-side issue with Slack HTTP API
Projects
None yet
Development

No branches or pull requests

2 participants