Rt-crontool and custom status

We have a series of ticket comes in that get auto shunned by our firewall. For stats tracking we want these tickets to take on a custom status we created called autoshun. I would like to use rt-crontool to automatically change the status of these tickets to autoshun. I created this new status in RT_SiteConfig.pm (I’ll cut and paste the Lifecycle section containing the new status configured at the end of this post). I restart Apache and the new status shows up in the search drop boxes etc. However when I attempt to assign this status using rt-crontool I get an error:

I run:
/opt/rt4/bin/rt-crontool --search RT::Search::FromSQL --search-arg “Status = ‘new’ AND Subject LIKE ‘WEBDAV’” --action RT::Action::SetStatus --action-arg autoshun --verbose --log debug --transaction first

Status doesn’t get set and following error returns:
[22514] [Thu Nov 8 15:09:56 2018] [debug]: Using internal Perl HTML -> text conversion (/opt/rt4/bin/…/lib/RT/Interface/Email.pm:1475)
62781:
Using transaction #840043
[22514] [Thu Nov 8 15:09:57 2018] [error]: Argument for SetStatus action is not valid status or one of set (/opt/rt4/bin/…/lib/RT/Action/SetStatus.pm:130)
62818:
Using transaction #840547
[22514] [Thu Nov 8 15:09:57 2018] [error]: Argument for SetStatus action is not valid status or one of set (/opt/rt4/bin/…/lib/RT/Action/SetStatus.pm:130)

If I run the some command for resolved it works fine. Strangely if try try other RT4 built in status such as stalled the same error occurs, seems like only resolved work? Am I missing something? Below is the Lifecycle section of my RT_SiteConfig.pm file

**Set(%Lifecycles,
default => {
initial => [qw(new)], # loc_qw
active => [qw(open stalled)], # loc_qw
inactive => [qw(resolved rejected deleted autoshun)], # loc_qw

    defaults => {
        on_create => 'new',
        approved  => 'open',
        denied    => 'rejected',
        reminder_on_open     => 'open',
        reminder_on_resolve  => 'resolved',
    },

    transitions => {
        ""       => [qw(new open resolved autoshun)],

        # from   => [ to list ],
        new      => [qw(    open stalled resolved rejected deleted autoshun)],
        open     => [qw(new      stalled resolved rejected deleted autoshun)],
        stalled  => [qw(new open         resolved rejected deleted autoshun)],
        resolved => [qw(new open stalled          rejected deleted autoshun)],
        rejected => [qw(new open stalled resolved          deleted autoshun)],
        deleted  => [qw(new open stalled resolved rejected         autoshun)],
        autoshun => [qw(new open stalled resolved rejected deleted         )],
    },
    rights => {
        '* -> deleted'  => 'DeleteTicket',
        '* -> *'        => 'ModifyTicket',
    },
    actions => [
        'new -> open'      => { label  => 'Open It', update => 'Respond' }, # loc{label}
        'new -> resolved'  => { label  => 'Resolve', update => 'Comment' }, # loc{label}
        'new -> autoshun'  => { label  => 'Autoshun', update => 'Comment' }, # loc{label}
        'new -> rejected'  => { label  => 'Reject',  update => 'Respond' }, # loc{label}
        'new -> deleted'   => { label  => 'Delete',                      }, # loc{label}
        'open -> stalled'  => { label  => 'Stall',   update => 'Comment' }, # loc{label}
        'open -> resolved' => { label  => 'Resolve', update => 'Comment' }, # loc{label}
        'open -> Autoshun' => { label  => 'Autoshun', update => 'Comment' }, # loc{label}
        'open -> rejected' => { label  => 'Reject',  update => 'Respond' }, # loc{label}
        'stalled -> open'  => { label  => 'Open It',                     }, # loc{label}
        'resolved -> open' => { label  => 'Re-open', update => 'Comment' }, # loc{label}
        'rejected -> open' => { label  => 'Re-open', update => 'Comment' }, # loc{label}
        'deleted -> open'  => { label  => 'Undelete',                    }, # loc{label}
        'autoshun -> resolved'  => { label  => 'Resolve', update => 'Comment' }, # loc{label}
    ],
},
assets => {
    type     => "asset",
    initial  => [
        'new' # loc
    ],
    active   => [
        'allocated', # loc
        'in-use' # loc
    ],
    inactive => [
        'recycled', # loc
        'stolen', # loc
        'deleted' # loc
    ],

    defaults => {
        on_create => 'new',
    },

    transitions => {
        ''        => [qw(new allocated in-use)],
        new       => [qw(allocated in-use stolen deleted)],
        allocated => [qw(in-use recycled stolen deleted)],
        "in-use"  => [qw(allocated recycled stolen deleted)],
        recycled  => [qw(allocated)],
        stolen    => [qw(allocated)],
        deleted   => [qw(allocated)],
    },
    rights => {
        '* -> *'        => 'ModifyAsset',
    },
    actions => {
        '* -> allocated' => {
            label => "Allocate" # loc
        },
        '* -> in-use'    => {
            label => "Now in-use" # loc
        },
        '* -> recycled'  => {
            label => "Recycle" # loc
        },
        '* -> stolen'    => {
            label => "Report stolen" # loc
        },
    },
},

don’t change lifecyle of the approvals, they are not capable to deal with

custom statuses

approvals => {
    initial         => [ 'new' ],
    active          => [ 'open', 'stalled' ],
    inactive        => [ 'resolved', 'rejected', 'deleted' ],

    defaults => {
        on_create => 'new',
        reminder_on_open     => 'open',
        reminder_on_resolve  => 'resolved',
    },

    transitions => {
        ''       => [qw(new open resolved)],

        # from   => [ to list ],
        new      => [qw(open stalled resolved rejected deleted)],
        open     => [qw(new stalled resolved rejected deleted)],
        stalled  => [qw(new open rejected resolved deleted)],
        resolved => [qw(new open stalled rejected deleted)],
        rejected => [qw(new open stalled resolved deleted)],
        deleted  => [qw(new open stalled rejected resolved)],

    },
    rights => {
        '* -> deleted'  => 'DeleteTicket',
        '* -> rejected' => 'ModifyTicket',
        '* -> *'        => 'ModifyTicket',
    },
    actions => [
        'new -> open'      => { label  => 'Open It', update => 'Respond' }, # loc{label}
        'new -> resolved'  => { label  => 'Resolve', update => 'Comment' }, # loc{label}
        'new -> rejected'  => { label  => 'Reject',  update => 'Respond' }, # loc{label}
        'new -> deleted'   => { label  => 'Delete',                      }, # loc{label}
        'open -> stalled'  => { label  => 'Stall',   update => 'Comment' }, # loc{label}
        'open -> resolved' => { label  => 'Resolve', update => 'Comment' }, # loc{label}
        'open -> rejected' => { label  => 'Reject',  update => 'Respond' }, # loc{label}
        'stalled -> open'  => { label  => 'Open It',                     }, # loc{label}
        'resolved -> open' => { label  => 'Re-open', update => 'Comment' }, # loc{label}
        'rejected -> open' => { label  => 'Re-open', update => 'Comment' }, # loc{label}
        'deleted -> open'  => { label  => 'Undelete',                    }, # loc{label}
    ],
},

);
**

Hmm, odd. At times like these I often take a copy of the file throwing the error (in your case /opt/rt4/lib/RT/Action/SetStatus.pm into /opt/rt4/local/lib/RT/Action/SetStatus.pm and then tweak line 130 in the local copy to something like:

$RT::Logger->error("Argument for SetStatus action '$argument' is not valid status or one of set. Current status is '$status'.");

Then clear Mason cache and restart web server and give it another go. This won’t fix the problem, but at least it lets you know that the argument is being passed in OK (or not as the case may be).

Looking at the code above line 130 in that module it appears that it checks that the requested action argument is valid in the lifecycle that the ticket is in, and for some reason that is failing in your case.

Thanks for the input, I made the change and see the variable seems to get passed properly. I assume that rt-crontool uses the default Lifecycle set and not some other one (we only use/have the default one far as I can tell. I also added a lookup for lifecycle. Below is the error returned, does lifecycle look correct?

[24794] [Thu Nov 8 18:14:35 2018] [debug]: Using internal Perl HTML -> text conversion (/opt/rt4/bin/…/lib/RT/Interface/Email.pm:1475)
62781:
Using transaction #840043
[24794] [Thu Nov 8 18:14:35 2018] [error]: Argument for SetStatus action ‘autoshun’ is not valid status or one of set. Current status is ‘open’. My lifecycle is ‘RT::Lifecycle=HASH(0x789ea80)’. (/opt/rt4/bin/…/local/lib/RT/Action/SetStatus.pm:130)
62818:
Using transaction #840547
[24794] [Thu Nov 8 18:14:35 2018] [error]: Argument for SetStatus action ‘autoshun’ is not valid status or one of set. Current status is ‘open’. My lifecycle is ‘RT::Lifecycle=HASH(0x7899768)’. (/opt/rt4/bin/…/local/lib/RT/Action/SetStatus.pm:130)

You might want to add ->Name to the lifecycle lookup to get the name of life cycle. All you’re seeing here is the address of the Perl hash that the RT::LifeCycle object is held in.