Giter VIP home page Giter VIP logo

Comments (12)

pyoor avatar pyoor commented on June 28, 2024

It's hard to tell what's going on without seeing the raw response from your bugzilla instance. Are you sure it's returning JSON? Try requesting https://my.bugzilla.instance.com/bugzilla/rest/bug/22789 in your browser.

from bugsy.

gsal avatar gsal commented on June 28, 2024

I am testing code from one of the examples, I can always type anything you can think of, catch and print.

I just tried what you suggest above, two things:

In the browser
if I type as shown above, I get an error message
If instead of just "rest", I type "rest.cgi", I get

{
   "code" : 410,
   "documentation" : "https://bugzilla.readthedocs.org/en/5.0/api/",
   "error" : true,
   "message" : "You must log in before using this part of Bugzilla."
}

from bugsy.

gsal avatar gsal commented on June 28, 2024

By the way, in the exercise above, I was already at the Bugzilla page but looking at another Bug, different number; so, presumaby, I was already logged in....but I guess I was not using the WebService ?

from bugsy.

pyoor avatar pyoor commented on June 28, 2024

Yeah, they would be separate. For the webservice you need to pass the X-Bugzilla-API-Key header in the request. I'd recommend printing out response.text() here.

from bugsy.

gsal avatar gsal commented on June 28, 2024

So, I am not using WebService? What is the name of what I am using? REST-API ?

I will try printing response, but I think a meeting coming up...give me a couple of hours.

Thanks for your assistance....I was starting to feel totally alone, I found about 3 or 4 python-based bugzilla programs but they all look a bit abandon and not touched in several years.

from bugsy.

pyoor avatar pyoor commented on June 28, 2024

So, I am not using WebService? What is the name of what I am using? REST-API ?

I just meant when you were browsing to the URL directly. When using bugsy, you're communicating with the webservice.

I will try printing response, but I think a meeting coming up...give me a couple of hours.

Thanks for your assistance....I was starting to feel totally alone, I found about 3 or 4 python-based bugzilla programs but they all look a bit abandon and not touched in several years.

And no worries. Happy to help.

from bugsy.

gsal avatar gsal commented on June 28, 2024

With the command bugzilla.get(22789), the program does not reach line 206, it fails here

Here is the session:

python
Python 3.9.18 (main, Sep  7 2023, 00:00:00) 
[GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bugsy
>>> bugzilla = bugsy.Bugsy(
...     bugzilla_url='https://my.bugzilla.instance.com/bugzilla/rest',
...     api_key="MY-KEY"
... )
>>> 
>>> bugzilla.authenticated
True
>>> bugzilla.get(22789)
Traceback (most recent call last):
  File "/home/gsal/bug/bugsyenv/lib64/python3.9/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib64/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 3 column 1 (char 4)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gsal/bug/bugsyenv/lib64/python3.9/site-packages/bugsy/bugsy.py", line 130, in get
    bug = self.request(
  File "/home/gsal/bug/bugsyenv/lib64/python3.9/site-packages/bugsy/bugsy.py", line 196, in request
    return self._handle_errors(self.session.request(method, url, **kwargs))
  File "/home/gsal/bug/bugsyenv/lib64/python3.9/site-packages/bugsy/bugsy.py", line 202, in _handle_errors
    result = response.json()
  File "/home/gsal/bug/bugsyenv/lib64/python3.9/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 3 column 1 (char 4)

By the way, of the various instances of file bugsy.py, one of the had:

            # Bugzilla 5.1+
            self.session.headers['X-Bugzilla-API-Key'] = self.api_key
            # Bugzilla 5.0
            self.session.params["Bugzilla_api_key"] = self.api_key

It just so happened that the file installed for me was the one with the V5.1 line, but my instance of Bugzilla is actually V5.0.4. Switching the line to the correct version did not make a difference, though.

from bugsy.

gsal avatar gsal commented on June 28, 2024

When catching the response before the program tries to handle it, this is what it is:

<Response [200]>

from bugsy.

pyoor avatar pyoor commented on June 28, 2024

With the command bugzilla.get(22789), the program does not reach line 206, it fails here

That's interesting. Those line numbers don't match up for me. Are you sure you're using the latest version of Bugsy? It should be failing here.

Also, can you add print(response.text) here to see the actual error coming back from the server.

By the way, of the various instances of file bugsy.py, one of the had:

            # Bugzilla 5.1+
            self.session.headers['X-Bugzilla-API-Key'] = self.api_key
            # Bugzilla 5.0
            self.session.params["Bugzilla_api_key"] = self.api_key

It just so happened that the file installed for me was the one with the V5.1 line, but my instance of Bugzilla is actually V5.0.4. Switching the line to the correct version did not make a difference, though.

The code above that you referenced is included in the latest version of Bugsy (which you should be using). The X-Bugzilla-API-Key header is used by Mozilla's version of Bugzilla which is what Bugsy was originally designed for AFAIK. I can't find anything in the official Bugzilla docs where this header eventually made it upstream.

I suspect that that's what you're experiencing. You're unable to authenticate with the web service and so requesting the bug throws.

from bugsy.

gsal avatar gsal commented on June 28, 2024

Yes, I don't think I am being authenticated. I continue to study and read the docs; one thing that caught my eye is that the Bugzilla docs mentioned that they encourage the use of api key over username and password...which is what I have been doing. They also mention that, basically, instead of login in they seem to expect to simply pass the api key with every call. BUT, even when I create the bugzilla object by including the url and the api key.....the api key does not seem to be pass to the bugzilla.get() command....hence the lack of authentication.

Let me hack this a bit and see if I can make it work, one way or another...I think I am onto something.

from bugsy.

gsal avatar gsal commented on June 28, 2024

Nope, not yet; I have tried a few things from Python and with curl, but nothing....It is looking like it is some kind of authentication issue; passing my api_key is not enought, maybe hitting the browser requires some Microsoft AzureAD authentication that has been adopted recently around here....will need to ask IT...or if you or anybody else knows about that, please share.

from bugsy.

gsal avatar gsal commented on June 28, 2024

Yeap, IT had disabled something at the webserver for testing; did not re-instate.

from bugsy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.