Skip to main content
Question

Convert Enum (Application Protocol) to String

  • August 5, 2026
  • 1 reply
  • 11 views

olivier_m
Forum|alt.badge.img

Due to the parsing of proxy logs, I need to “re-build” the URL from network.application_protocol and target.url: $url = strings.concat($e.network.application_protocol, "://", $e.target.url)

I’m getting the following error:
compilation error compiling query: validating query: expect type [string int float], got type backstory.Network.ApplicationProtocol for "e.udm.network.application_protocol"

I guess I need to convert the enum to string.
Any solutions for that ?

Thanks,

1 reply

GromeroSec
Forum|alt.badge.img+6
  • Bronze 3
  • August 5, 2026

Hey man ! i hope you want to do this on the outcome section as this will not work on the events sections: 

Short answer: network.application_protocol is an enum (backstory.Network.ApplicationProtocol), and strings.concat only accepts string / int / float, so you can't pass the raw enum into it.

 

There's also no native cast for it — cast.as_string only handles INT, BYTES, and BOOL, not enums. So your instinct is right, you just need a different mechanism to get a string out of the enum.

 

The trick: enums can be compared against their string labels, so you use if() in the outcome section to emit a plain string, then concat that.

Single-event rule:
yaral
outcome:
  // get the enum values as strings on anothe variable
  $protocol_str = if($e.network.application_protocol = "HTTPS", "https",
                  if($e.network.application_protocol = "HTTP",  "http", "http"))

  // now concat receives pure strings and compiles fine
  $url = strings.concat($protocol_str, "://", $e.target.url)

Multi-event rule (non-constant outcome vars need an aggregation function):
yaral
outcome:
  $url = array_distinct(strings.concat(
           if($e.network.application_protocol = "HTTPS", "https",
           if($e.network.application_protocol = "HTTP",  "http", "http")),
           "://",
           $e.target.url))

 

hope this helps you