It looks like the following line is missing from your portrait-bits.tcl file for some reason.
set portrait_id [database_to_tcl_string $db "select lob from users where user_id = $user_id"]