yarl / pattypan

Upload files to Wikimedia Commons. The Spreadsheet Way.
https://commons.wikimedia.org/wiki/Commons:Pattypan
MIT License
56 stars 37 forks source link

Pattypan should send a correct user agent when making request to commons.wikimedia.org #146

Closed reedy closed 2 years ago

reedy commented 2 years ago

Following on from https://github.com/yarl/pattypan/issues/138 and the Phabricator tasks...

Can someone please look and verify pattypan is actually using its own user agent in requests?

https://github.com/yarl/pattypan/blob/2809ce78ff20ec13f7e418bd0e2ad1750bc6e085/src/pattypan/Settings.java#L46

Looking at some of the code, it does seem there is some setup for it such as surrounding the above, but looking at the logs (from the Wikimedia side), it doesn't seem to result in any entries, which is odd.

vicuna seems to be fine.

Abbe98 commented 2 years ago

It appears to be used in the session setup: https://github.com/yarl/pattypan/blob/2809ce78ff20ec13f7e418bd0e2ad1750bc6e085/src/pattypan/Session.java#L58

reedy commented 2 years ago

Yeah, which is why I've created the task.

The useragent doesn't seem to be making it to Wikimedia's Logstash servers which makes me feel like something in the plumbing isn't quite right here.

I noticed https://github.com/yarl/vicuna/commit/0dc286fb48a5c6d8a86c1673266b9d76cbeb84ad where it was done in a few more places, I'm not sure specifically why like that

Abbe98 commented 2 years ago

We only call setUserAgent once because we only got one instance of the Wiki.java class.

I will need to have a look when I got a debugger at hand, I assume that WIKI.setUserAgent(Settings.USERAGENT); is either dead code or we lose the state of WIKI somewhere.

Abbe98 commented 2 years ago

The initialization of the Wiki.java session in Session.java was overwritten by the one in Main.java. I removed the one in Session.java as it would end up being overwritten anyway. Marking this for the 22.03 release.

reedy commented 2 years ago

Yay. Thanks!