# Irule Error message

**URL:** <https://community.f5.com/t/irule-error-message/37616>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [August 13, 2007, 5:05pm UTC](https://community.f5.com/t/irule-error-message/37616 "2007-08-13T17:05:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Mangret](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@Michael\_Mangret](https://community.f5.com/u/Michael_Mangret)\
**Post date:** [August 13, 2007, 5:05pm UTC](https://community.f5.com/t/irule-error-message/37616/1 "2007-08-13T17:05:50Z")

</div>

Can anyone tell me what might be wrong with my Irule? It seems to be working. I get the message Forbidden when I send a call with the header x-moz set, but I still get this error message in my log.

Error Message:

Aug 13 12:59:27 tmm tmm[715]: 01220001:3: TCL error: Rule xmoz\_irule - can’t read “host\_pool”: no such variable while executing “if { $host\_pool ne “” } { pool $host\_pool }”

Irule:

when HTTP\_REQUEST {

if {[string tolower [HTTP::header x-moz:] ] contains “prefetch” } {

HTTP::respond 403 content “Forbidden”}

else {set host\_pool [findclass [HTTP::host] $::DSHostPoolMap " "] }

if { $host\_pool ne “” } {

pool $host\_pool }

}

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [August 13, 2007, 5:35pm UTC](https://community.f5.com/t/irule-error-message/37616/2 "2007-08-13T17:35:49Z")

</div>

You’re getting the TCL error because $host\_pool isn’t being set for every request--but is being referenced in every request.

This is your original rule, formatted for easier reading:

```tcl
when HTTP_REQUEST {
   if {[string tolower [HTTP::header x-moz:] ] contains "prefetch" } {
      HTTP::respond 403 content "Forbidden"
   } else {
      set host_pool [findclass [HTTP::host] $::DSHostPoolMap " "]
   }
   if { $host_pool ne "" } {
      pool $host_pool
   }
}

```

Note that on every request, the $host\_pool condition is being checked. It’s only being set if the x-moz header check is false.

You might want to move the $host\_pool check into the else. Or you could check to see that the $host\_pool variable is set and not blank using [info exists host\_pool].

You should also consider specifying what you want to happen if the [HTTP::host] value is not found in the datagroup.

Here’s an example:

```tcl
when HTTP_REQUEST {
   if {[string tolower [HTTP::header x-moz]] eq "prefetch" } {
      HTTP::respond 403 content "Forbidden"
   } else {
      set host_pool [findclass [string tolower [HTTP::host]] $::DSHostPoolMap " "]
      if { $host_pool ne "" } {
         pool $host_pool
      } else {
         pool default_pool
      } 
   }
}

```

Aaron

---

<div class="post-metadata">

**Author:** ![Michael\_Mangret](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@Michael\_Mangret](https://community.f5.com/u/Michael_Mangret)\
**Post date:** [August 13, 2007, 7:10pm UTC](https://community.f5.com/t/irule-error-message/37616/3 "2007-08-13T19:10:09Z")

</div>

Thank you very much. I will try to add the defaul pool and see what happens.
