flottbot icon indicating copy to clipboard operation
flottbot copied to clipboard

add ability to customize `Variable '<variable name>' has not been defined` message

Open wass3rw3rk opened this issue 5 months ago • 0 comments

when a http action is used that sends a request to populate certain variables, and the request times out, the bot currently returns Variable '<variable name>' has not been defined for any variables that do not get populated. an internal request was filed for the desire to provide a more meaningful message.

desired functionality:

  • change default message (<action_name> action timed out was suggested)
  • per action customization (adding timeout_message field)
  • silently fail if timeout_message is empty string

to note: "not defined" message does not exclusively happen when requests time out, so perhaps the default message should be something else, or maybe there is a need to define messages for other scenarios, such as when an API returns any non-200 messages.

example rules file:

name: test
active: true
respond: test
actions:
  - name: test rule
    type: GET
    url: http://somehost.example.com/endpoint
    expose_json_fields:
      output: |-
        {{if and (ge ${_raw_http_status} 200) (lt ${_raw_http_status} 300) }}
        {{.message}}
        {{else}}
        request failed with http status code `${_raw_http_status}`
        {{end}}
    timeout: 1
format_output: "${output}" 
direct_message_only: false
help_text: "Sample rules to reproduce Variable `output` has not been defined issue."
include_in_help: true

wass3rw3rk avatar Sep 17 '24 15:09 wass3rw3rk