Skip to content

Getting JSONDecodeError on bad credentials #390

@thomasbach-dev

Description

@thomasbach-dev

Trying to delete an object with wrong credentials unexpectedly throws a JSONDecodeError. To reproduce:

  • initiate a connector to an existing Infoblox instance, but using wrong credentials,
  • call connector.delete_object("no-matter-what-the-reference") (you might have to call it twice, see below)

Obtained stacktrace:

../../../../venv/lib/python3.12/site-packages/infoblox_client/connector.py:55: in callee
    return func(*args, **kwargs)
../../../../venv/lib/python3.12/site-packages/infoblox_client/connector.py:76: in wrapper
    return func(self, *args, **kwargs)
../../../../venv/lib/python3.12/site-packages/infoblox_client/connector.py:707: in delete_object
    response=jsonutils.loads(r.content),
../../../../venv/lib/python3.12/site-packages/oslo_serialization/jsonutils.py:250: in loads
    return json.loads(encodeutils.safe_decode(s, encoding), **kwargs)
/nix/store/zv1kaq7f1q20x62kbjv6pfjygw5jmwl6-python3-3.12.7/lib/python3.12/json/__init__.py:346: in loads
    return _default_decoder.decode(s)
/nix/store/zv1kaq7f1q20x62kbjv6pfjygw5jmwl6-python3-3.12.7/lib/python3.12/json/decoder.py:337: in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

The problematic line seems to be https://github.com/infobloxopen/infoblox-client/blob/master/infoblox_client/connector.py#L707 -- the value of r.content is

b'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>403 Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\n<p>You don\'t have permission to access this resource.</p>\n</body></html>\n'

There is some inconsistency in the behaviour -- I only get said stacktrace on a second run. But it is definitely reproducible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions