robusta-dev/robusta

Webhook sink throws Type Error when trying to write JSON

Opened this issue · 1 comments

To Reproduce
Steps to reproduce the behavior:
Give the config:

globalConfig:
  signing_key: <>
  account_id: <>
sinksConfig:
  - robusta_sink:
      name: robusta_ui_sink
      token: <>
  - slack_sink:
      name: dev_sink
      slack_channel: robusta
      api_key: <>
      stop: false
  - webhook_sink:
      name: webhook_sink
      url: <>
      format: "json"
enablePrometheusStack: false
enablePlatformPlaybooks: true
runner:
  sendAdditionalTelemetry: false

customPlaybooks:
- triggers:
    - on_deployment_update:
        change_filters:
          ignore: # These are ignored by default
          - status
          - metadata.generation
          - metadata.resourceVersion
          - metadata.managedFields
          - spec.replicas
          include:
            - spec.template.spec.containers[0]
            - spec.strategy
  actions:
    - resource_babysitter: {}
    - customise_finding:
        severity: MEDIUM
        title: "New changes in $kind/$namespace/$name"
  sinks:
    - dev_sink # Optional
    - webhook_sink

Expected behavior
I would expect to have a JSON payload posted to the webhook URL.

Additional context

TypeError: keys must be str, int, float, bool or None, not type
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.9/json/encoder.py", line 257, in iterencode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.9/json/encoder.py", line 199, in encode
    return cls(
  File "/usr/local/lib/python3.9/json/__init__.py", line 234, in dumps
    finding_dict = json.loads(json.dumps(finding, default=lambda o: getattr(o, '__dict__', str(o))))
  File "/app/src/robusta/core/sinks/webhook/webhook_sink.py", line 75, in __write_json
    self.__write_json(finding, platform_enabled)
  File "/app/src/robusta/core/sinks/webhook/webhook_sink.py", line 32, in write_finding
    sink.write_finding(finding_copy, self.registry.get_sinks().platform_enabled)
  File "/app/src/robusta/core/playbooks/playbooks_event_handler_impl.py", line 317, in __handle_findings
Traceback (most recent call last):
2024-05-06 13:45:23.593 ERROR    Failed to publish finding to sink webhook_sink

Hi 👋, thanks for opening an issue! Please note, it may take some time for us to respond, but we'll get back to you as soon as we can!

  • 💬 Slack Community: Join Robusta team and other contributors on Slack here.
  • 📖 Docs: Find our documentation here.
  • 🎥 YouTube Channel: Watch our videos here.