bluefeet / GitLab-API-v4

A complete GitLab API v4 client.
https://metacpan.org/pod/GitLab::API::v4
Other
20 stars 23 forks source link

"malformed JSON string" when trying to mass-delete runners #38

Closed tvo6 closed 5 years ago

tvo6 commented 5 years ago

Hello,

I try to mass-delete about 400 runners, and I get an error.

My piece of code (I'm using a token for the owner of group/runners which I'm trying to delete):

my $api = GitLab::API::v4->new(
    url           => 'https://gitlab.my-domain.net/api/v4/',
    private_token => $token,
);
my $runners = $api->paginator('runners');
while (my $r = $runners->next()) {
    my $deleterunner = $api->delete_runner(
        $r->{'id'},
    );
}

When I execute this, I'm getting this error:

malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/share/perl5/GitLab/API/v4/RESTClient.pm line 179.

And only 1 (one) runner is deleted. I don't understand what's going on (am I doing something wrong?)… I used a bash loop to execute my perl program 400 times and it's ok, but I'd like to have it working correctly.

Thanks!

Edit: I'm using libgitlab-api-v4-perl version 0.16-1 on Debian buster, and tested on sid / version 0.22-1, the error is the same.

bluefeet commented 5 years ago

Well that error message sure is lame. I should get that fixed up as well so it has some more specifics.

I don't see anything wrong with what you are doing.

You say "used a bash loop to execute my perl program 400 times and it's ok". What do you mean? It only failed once and the other 400 times it worked?

tvo6 commented 5 years ago

I don't see anything wrong with what you are doing.

OK, thanks :)

You say "used a bash loop to execute my perl program 400 times and it's ok". What do you mean? It only failed once and the other 400 times it worked?

No, I did something like:

for i in $(seq 0 400); do ./remove-runners.pl <mytoken>; done

and it fails every time, but removes one runner…

bluefeet commented 5 years ago

Version 0.23 has been released, and will be arriving at your local CPAN mirror within an hour or two.