sh19910711 / git-contest

Git extension for the online judges
https://rubygems.org/gems/git-contest
MIT License
11 stars 5 forks source link

`get_submission_id': undefined method `xpath' for nil:NilClass (NoMethodError) #42

Closed pathikrit closed 9 years ago

pathikrit commented 9 years ago

It submitted correctly, but I got this error:

> git contest submit codeforces -c 535 -p C --source src/main/scala/C535.scala
@start: submit
@submit: logging in...
@submit: login ok
@submit: doing...
@submit: done
/Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/codeforces_driver.rb:191:in `get_submission_id': undefined method `xpath' for nil:NilClass (NoMethodError)
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/codeforces_driver.rb:136:in `submit_ext'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/base.rb:137:in `submit'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/sub_commands/submit_command.rb:166:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/main_command.rb:34:in `call_subcommand'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/main_command.rb:21:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/bin/git-contest:15:in `<top (required)>'
        from /usr/bin/git-contest:23:in `load'
        from /usr/bin/git-contest:23:in `<main>'
sh19910711 commented 9 years ago

Thank you for the report. I have just been able to reproduce the error in my machine when I submit an invalid source code which contains no object keyword (but I don't know what is invalid in codeforces). Could you check whether you can submit the same source code from web browser? I want to know the result after submit, since it might be helpful to us.

pathikrit commented 9 years ago

I got this error for problems 514A and 535C. See here: http://codeforces.com/submissions/wrick

It did submit to codeforces but it exited with above error:

This is the command I ran:

git contest submit codeforces -c 535 -p C --source src/main/scala/C535.scala

This is the source file: See submission id #10747412 here

In general, I am using this: https://github.com/pathikrit/ScalaForces

Specifically, this is how I am invoking git-contest: https://github.com/pathikrit/ScalaForces/blob/master/run.sh#L36-L46

sh19910711 commented 9 years ago

git contest submit codeforces -c 535 -p C --source src/main/scala/C535.scala

Their options looks good.

https://github.com/pathikrit/ScalaForces/blob/master/run.sh#L36-L46

Pretty good.

They reminds me, the codeforces does not accept the same submission as before, otherwise it would return an error message after submitting a source code (like "duplicate error" in the submit page of codeforces). I wonder if it points to your issue.

However, the codeforces driver of git-contest, which is a thing to submit solutions, have not supported such error messages yet. So I think that we have to improve error handling of the driver at first.

pathikrit commented 9 years ago

Hi, I just did http://codeforces.com/contest/540 live and I kept getting same error (although it did manage to submit each time):

Submit 540/B? Y
Submitting src/main/scala/B540.scala ...
@start: submit
@submit: logging in...
@submit: login ok
@submit: doing...
@submit: done
/Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/codeforces_driver.rb:191:in `get_submission_id': undefined method `xpath' for nil:NilClass (NoMethodError)
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/codeforces_driver.rb:136:in `submit_ext'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/base.rb:137:in `submit'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/sub_commands/submit_command.rb:166:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/main_command.rb:34:in `call_subcommand'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/main_command.rb:21:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/bin/git-contest:15:in `<top (required)>'
        from /usr/bin/git-contest:23:in `load'
        from /usr/bin/git-contest:23:in `<main>'
sh19910711 commented 9 years ago

Hi, pathikrit. Thanks for the report again.

Today, I have added a debug mode to git-contest. So could you please try the devlopment version of git-contest? It can be installed by such as the following three steps:

shell> git clone -b issue-42 https://github.com/sh19910711/git-contest.git
Cloning into 'git-contest'...
remote: Counting objects: 2245, done.
remote: Total 2245 (delta 0), reused 0 (delta 0), pack-reused 2245
Receiving objects: 100% (2245/2245), 312.70 KiB | 306.00 KiB/s, done.
Resolving deltas: 100% (1261/1261), done.
Checking connectivity... done.

shell> cd git-contest/
shell> bundle exec rake install
git-contest 0.2.6 built to pkg/git-contest-0.2.6.gem.
git-contest (0.2.6) installed.

And you can enable the debug mode by such as the following command (-d or --debug option):

shell> git-contest submit cf -c 540 -p A -s tmp/main.scala -d

After that, could you paste the result with debug mode? I would like to see the result of that.

sh19910711 commented 9 years ago

FYI, here are my results:

OK
shell> git contest submit cf -c 540 -p A -s tmp/main.scala -d
@start: submit
@submit: logging in...
#DEBUG: login_page = http://codeforces.com/enter
@submit: login ok
@submit: doing...
#DEBUG: submit_page = http://codeforces.com/contest/540/submit
#DEBUG: result_page = http://codeforces.com/contest/540/my
@submit: done
@result: waiting.....

@result: Submission Result
  submission id: 10979927
  status: Accepted

@finish
Error
shell> git contest submit cf -c 540 -p A -s tmp/main.scala -d
@start: submit
@submit: logging in...
#DEBUG: login_page = http://codeforces.com/enter
@submit: login ok
@submit: doing...
#DEBUG: submit_page = http://codeforces.com/contest/540/submit
#DEBUG: result_page = http://codeforces.com/contest/540/submit?csrf_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@submit: done
/home/user/workspace/git-contest/lib/contest/driver/codeforces_driver.rb:194:in `get_submission_id': undefined method `xpath' for nil:NilClass (NoMethodError)
        from /home/user/workspace/git-contest/lib/contest/driver/codeforces_driver.rb:139:in `submit_ext'
        from /home/user/workspace/git-contest/lib/contest/driver/base.rb:146:in `submit'
        from /home/user/workspace/git-contest/lib/git/contest/command_line/sub_commands/submit_command.rb:166:in `run'
        from /home/user/workspace/git-contest/lib/git/contest/command_line/main_command.rb:34:in `call_subcommand'
        from /home/user/workspace/git-contest/lib/git/contest/command_line/main_command.rb:21:in `run'
        from ./bin/git-contest:15:in `<main>'
sh19910711 commented 9 years ago

P.S. You might need to run bundle install command before bundle exec rake install:

shell> cd git-contest/
shell> bundle install
... messages ...
shell> bundle exec rake install
git-contest 0.2.6 built to pkg/git-contest-0.2.6.gem.
git-contest (0.2.6) installed.

If you cannot use bundle command, try the following command:

shell> gem install bundler

Thanks.

pathikrit commented 9 years ago

Thank you for looking into this. I followed your instructions and installed 0.2.6.

First time doing contest 544:

Submit 544/A? Y
Submitting src/main/scala/A544.scala ...
+ git contest submit codeforces -c 544 -p A -s src/main/scala/A544.scala -d
@start: submit
@submit: logging in...
#DEBUG: login_page = http://codeforces.com/enter
@submit: login ok
@submit: doing...
#DEBUG: submit_page = http://codeforces.com/contest/544/submit
#DEBUG: result_page = http://codeforces.com/contest/544/my
@submit: done
/Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/codeforces_driver.rb:194:in `get_submission_id': undefined method `xpath' for nil:NilClass (NoMethodError)
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/codeforces_driver.rb:139:in `submit_ext'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/base.rb:146:in `submit'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/sub_commands/submit_command.rb:166:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/main_command.rb:34:in `call_subcommand'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/main_command.rb:21:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/bin/git-contest:15:in `<top (required)>'
        from /usr/bin/git-contest:23:in `load'
        from /usr/bin/git-contest:23:in `<main>'
pathikrit commented 9 years ago

I see there is a difference in the "result_page" between your output and mine. I wonder why?

Another difference I can think of is you probably login using your username/password. I also do that but when I first joined CodeForces, I used to sign in using GMail OpenId option.

sh19910711 commented 9 years ago

Hi pathikrit, thanks for the reports.

Another difference I can think of is you probably login using your username/password.

It's a good insight for debugging this issue :-) I'll take a look later.


Today, I have added a logic to show an error message from Codeforces. Could you try it again? In order to update the git-contest, I recommend you to do the previous steps again (git clone -> bundle install -> bundle exec rake install)

Here is a result with a error of duplicated case:

@start: submit
@submit: logging in...
#DEBUG: login_page = http://codeforces.com/enter
@submit: login ok
@submit: doing...
#DEBUG: submit_page = http://codeforces.com/contest/544/submit
#DEBUG: result_page = http://codeforces.com/contest/544/submit?csrf_token=XXX
@submit: done
### ERROR ###
You have submitted exactly the same code before

Please let me know if any errors happen (or nothing happens).

pathikrit commented 9 years ago

I tried submitting an already submitted solution. Here is what I got:

@start: submit
@submit: logging in...
#DEBUG: login_page = http://codeforces.com/enter
@submit: login ok
@submit: doing...
#DEBUG: submit_page = http://codeforces.com/contest/544/submit
#DEBUG: result_page = http://codeforces.com/contest/544/my
@submit: done
/Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/codeforces_driver.rb:211:in `get_submission_id': undefined method `xpath' for nil:NilClass (NoMethodError)
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/codeforces_driver.rb:146:in `submit_ext'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/contest/driver/base.rb:146:in `submit'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/sub_commands/submit_command.rb:166:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/main_command.rb:34:in `call_subcommand'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/lib/git/contest/command_line/main_command.rb:21:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/git-contest-0.2.6/bin/git-contest:15:in `<top (required)>'
        from /usr/bin/git-contest:23:in `load'
        from /usr/bin/git-contest:23:in `<main>'

I see there is a difference between you and me. You see this:

#DEBUG: result_page = http://codeforces.com/contest/544/submit?csrf_token=XXX

I see this:

#DEBUG: result_page = http://codeforces.com/contest/544/my

also, maybe increment the version to 0.2.7 so I can be sure that I have the same version?

pathikrit commented 9 years ago

Also, these are my versions:

 bundle -v
Bundler version 1.9.6

ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
sh19910711 commented 9 years ago

also, maybe increment the version to 0.2.7 so I can be sure that I have the same version?

It's nice idea to rename version. You can modify it in lib/git/contest/version.rb (and you might need to re-install it by bundle exec rake install).

Also, these are my versions:

Could you paste your Gemfile.lock here? It will be generated in the root directory of git-contest after running bundle install.

pathikrit commented 9 years ago

Hi, it is easiest to resolve this if I temporarily give you my credentials. Can you email me at pathikritbhowmick@msn.com so I can temporarily let you access my account and see what is going on?

Thank you!

sh19910711 commented 9 years ago

Hi pathikrit,

Yeah, it's also a nice idea, but in order to avoid some troubles, please make sure to prepare new account which you can face with the same issue.

I've sent a message to you from sh19910711 at gmail.com.

pathikrit commented 9 years ago

I replied. Check your email. Thank you!

sh19910711 commented 9 years ago

Hi pathikrit, I couldn't login. Could you check the account?

pathikrit commented 9 years ago

Try lowercasing the username and password I sent you. Sorry for the confusion. Thank you!

sh19910711 commented 9 years ago

Hello pathikrit,

I could submit solutions with Scala from git-contest to your account. It seems that you are using the Mac OS X, so the issue might be a special case on Mac OS X. We also need to test it.

pathikrit commented 9 years ago

Ah ok! Thanks for looking into it. Nothing we can do about the OS unfortunately. It works in the sense it does submit so it is okay for now. Thank you again!

pathikrit commented 9 years ago

I got a new Macbook and it worked in there! So I might have an old ruby or something with my env in my old laptop?

Submitting target/submissions/_554C.scala ...
@start: submit
@submit: logging in...
@submit: login ok
@submit: doing...
@submit: done
@result: waiting......

@result: Submission Result
  submission id: 11752155
  status: Accepted

@finish
sh19910711 commented 9 years ago

I got a new Macbook and it worked in there!

@pathikrit Hey, that is good!

So I might have an old ruby or something with my env in my old laptop?

Maybe, yes. Let me know which version of Mac you have in your old laptop?