Menu

#9 getPRByNumber() does not return undef with non-existent PR

default
closed-fixed
rpcme
default (7)
5
2014-08-15
2005-09-07
No

If getPRByNumber() is called with a PR that does not
exist in the database, then it returns an empty object.
I think that the correct behaviour is to return undef,
to indicate the problem.

The cause is that the lack of a PR is not returned from
the daemon as an error, rather as '220 No PRs Match'.
The patch below treats this as an error condition.

--- Net-Gnats-0.06.orig/Gnats.pm 2003-11-08
03:41:47.000000000 +1100
+++ Net-Gnats-0.06/Gnats.pm 2005-09-07
14:47:08.984710000 +1000
@@ -529,7 +529,7 @@
}

($code, $response) = $self->_doGnatsCmd("QUER $num");
- if (not $self->_isCodeOK($code)) {
+ if ((not $self->_isCodeOK($code)) || $code == 220) {
$self->_markError($code, $response);
return undef;
}

Discussion

  • Mike Hoolehan

    Mike Hoolehan - 2005-09-07

    Logged In: YES
    user_id=323038

    Thanks malcomp. I'll try to do a release this weekend
    incorporating this patch.

     
  • rpcme

    rpcme - 2014-08-15

    Confirmed this as an issue.

    Added regress test to t/live.t

    Issue is _is_code_ok sees the 220 as OK but no PRs match.

    Ultimately, Net::Gnats::PR->parse should error ... but it is solved in the meantime ... and the function will probably move to Net::Gnats::Response anyway.

     
  • rpcme

    rpcme - 2014-08-15
    • status: open --> closed-fixed
    • assigned_to: Mike Hoolehan --> thacker
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.