WasmResult Context::getProperty(absl::string_view path, std::string* result) {
  using google::api::expr::runtime::CelValue;
  using google::api::expr::runtime::FieldBackedListImpl;
  using google::api::expr::runtime::FieldBackedMapImpl;

  bool first = true;
  CelValue value;
  Protobuf::Arena arena;
  const StreamInfo::StreamInfo* info = getConstRequestStreamInfo();
  const auto request_headers = request_headers_ ? request_headers_ : access_log_request_headers_;
  const auto response_headers =
      response_headers_ ? response_headers_ : access_log_response_headers_;
  const auto response_trailers =
      response_trailers_ ? response_trailers_ : access_log_response_trailers_;

  size_t start = 0;
  while (true) {
    if (start >= path.size()) {
      break;
    }

    size_t end = path.find('\0', start);
    if (end == absl::string_view::npos) {
      // this should not happen unless the input string is not null-terminated in the view
      return WasmResult::ParseFailure;
    }
    auto part = path.substr(start, end - start);
    start = end + 1;

    // top-level ident
    if (first) {
      first = false;
      if (part == "metadata") {
        value = CelValue::CreateMessage(&info->dynamicMetadata(), &arena);
      } else if (part == "filter_state") {
        value = CelValue::CreateMap(
            Protobuf::Arena::Create<WasmStateWrapper>(&arena, info->filterState()));
      } else if (part == "request") {
        value = CelValue::CreateMap(Protobuf::Arena::Create<Filters::Common::Expr::RequestWrapper>(
            &arena, request_headers, *info));
      } else if (part == "response") {
        value = CelValue::CreateMap(Protobuf::Arena::Create<Filters::Common::Expr::ResponseWrapper>(
            &arena, response_headers, response_trailers, *info));
      } else if (part == "connection") {
        value = CelValue::CreateMap(
            Protobuf::Arena::Create<Filters::Common::Expr::ConnectionWrapper>(&arena, *info));
      } else if (part == "upstream") {
        value = CelValue::CreateMap(
            Protobuf::Arena::Create<Filters::Common::Expr::UpstreamWrapper>(&arena, *info));
      } else if (part == "node") {
        value = CelValue::CreateMessage(&plugin_->local_info_.node(), &arena);
      } else if (part == "source") {
        value = CelValue::CreateMap(
            Protobuf::Arena::Create<Filters::Common::Expr::PeerWrapper>(&arena, *info, false));
      } else if (part == "destination") {
        value = CelValue::CreateMap(
            Protobuf::Arena::Create<Filters::Common::Expr::PeerWrapper>(&arena, *info, true));
      } else if (part == "request_protocol") {
        // TODO(kyessenov) move this upstream to CEL context
        if (info->protocol().has_value()) {
          value =
              CelValue::CreateString(&Http::Utility::getProtocolString(info->protocol().value()));
        } else {
          return WasmResult::NotFound;
        }
        // Reflective accessors
      } else if (part == "listener_direction") {
        value = CelValue::CreateInt64(plugin_->direction_);
      } else if (part == "listener_metadata") {
        value = CelValue::CreateMessage(plugin_->listener_metadata_, &arena);
      } else if (part == "cluster_name" && info->upstreamHost() != nullptr) {
        value = CelValue::CreateString(&info->upstreamHost()->cluster().name());
      } else if (part == "cluster_metadata" && info->upstreamHost() != nullptr) {
        value = CelValue::CreateMessage(&info->upstreamHost()->cluster().metadata(), &arena);
      } else if (part == "route_name") {
        value = CelValue::CreateString(&info->getRouteName());
      } else if (part == "route_metadata" && info->routeEntry() != nullptr) {
        value = CelValue::CreateMessage(&info->routeEntry()->metadata(), &arena);
      } else {
        return WasmResult::NotFound;
      }
      continue;
    }

    if (value.IsMap()) {
      auto& map = *value.MapOrDie();
      auto field = map[CelValue::CreateString(part)];
      if (field.has_value()) {
        value = field.value();
      } else {
        return {};
      }
    } else if (value.IsMessage()) {
      auto msg = value.MessageOrDie();
      if (msg == nullptr) {
        return {};
      }
      const Protobuf::Descriptor* desc = msg->GetDescriptor();
      const Protobuf::FieldDescriptor* field_desc = desc->FindFieldByName(std::string(part));
      if (field_desc == nullptr) {
        return {};
      } else if (field_desc->is_map()) {
        value = CelValue::CreateMap(
            Protobuf::Arena::Create<FieldBackedMapImpl>(&arena, msg, field_desc, &arena));
      } else if (field_desc->is_repeated()) {
        value = CelValue::CreateList(
            Protobuf::Arena::Create<FieldBackedListImpl>(&arena, msg, field_desc, &arena));
      } else {
        auto status =
            google::api::expr::runtime::CreateValueFromSingleField(msg, field_desc, &arena, &value);
        if (!status.ok()) {
          return {};
        }
      }
    } else {
      return {};
    }
  }

  return serializeValue(value, result);
}