question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] bool type error

See original GitHub issue

I believe I have found a bug in drf-access-policy. During some requests I receive the following 500 error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 497, in dispatch
    self.initial(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 415, in initial
    self.check_permissions(request)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 332, in check_permissions
    if not permission.has_permission(request, self):
  File "/usr/local/lib/python3.8/site-packages/rest_access_policy/access_policy.py", line 26, in has_permission
    return self._evaluate_statements(statements, request, view, action)
  File "/usr/local/lib/python3.8/site-packages/rest_access_policy/access_policy.py", line 62, in _evaluate_statements
    matched = self._get_statements_matching_context_conditions(
  File "/usr/local/lib/python3.8/site-packages/rest_access_policy/access_policy.py", line 181, in _get_statements_matching_context_conditions
    passed = bool(boolExpr.parseString(condition)[0])
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1943, in parseString
    loc, tokens = self._parse(instring, 0)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4462, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4462, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4254, in parseImpl
    ret = e._parse(instring, loc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4462, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4254, in parseImpl
    ret = e._parse(instring, loc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4462, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4254, in parseImpl
    ret = e._parse(instring, loc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4069, in parseImpl
    loc, exprtokens = e._parse(instring, loc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4462, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4462, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4254, in parseImpl
    ret = e._parse(instring, loc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4069, in parseImpl
    loc, exprtokens = e._parse(instring, loc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4462, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4052, in parseImpl
    loc, resultlist = self.exprs[0]._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4462, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4254, in parseImpl
    ret = e._parse(instring, loc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4462, in parseImpl
    return self.expr._parse(instring, loc, doActions, callPreParse=False)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1683, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 4254, in parseImpl
    ret = e._parse(instring, loc, doActions)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1716, in _parseNoCache
    tokens = fn(instring, tokensStart, retTokens)
  File "/usr/local/lib/python3.8/site-packages/pyparsing.py", line 1316, in wrapper
    ret = func(*args[limit[0]:])
TypeError: __init__() missing 1 required positional argument: 't'

The error seems to stem from File "/usr/local/lib/python3.8/site-packages/rest_access_policy/access_policy.py", line 181, in _get_statements_matching_context_conditions

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rsinger86commented, Jul 5, 2021

Thanks 🙂. I’ll plan to do the 1.0 update later today, it’s pretty minor, the main thing is communicating the breaking change in the docs.

On Mon, Jul 5, 2021, 4:03 PM Michael Honaker @.***> wrote:

@rsinger86 https://github.com/rsinger86 Thank you for your response and for this project! It has really helped ease the development of my product.

How can I go about avoiding this issue (Im planning on opening up my project to beta and this is kinda the last blocker)? I’ve seen this happen with both simple method conditions as well as a basic complex expression e.g. (is_adminoffice or is_sysadmin) so I’m not really sure how to stop/avoid it. I can also downgrade to 0.8.6 if this error does not occur there.

Thank you again for your help.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rsinger86/drf-access-policy/issues/66#issuecomment-874327095, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB32I5THDBULOZAYDYXCCJTTWIM2BANCNFSM47AQ7MZQ .

0reactions
HonakerMcommented, Jul 6, 2021

@rsinger86 just checked and it works perfectly!! Will let you know if I encounter the error again. Thank you again for all your work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug: Boolean type literals misbehaving · Issue #10432
Types of property 'success' are incompatible. Type 'boolean' is not assignable to type 'false'. result.ts(8,16): error TS2322: Type ...
Read more >
ERROR! Unexpected Exception, this is probably a bug
I've got an error with Ansible, that I don't understand: ERROR! Unexpected Exception, this is probably a bug: argument of type 'bool' is...
Read more >
An error from a simple test for BOOL type in visual C++
Try adding #include <windows.h> before the windef.h header. But unless you need to interact with code using BOOL you should probably use the ......
Read more >
1571292 - error: '~' on an expression of type bool [-Werror= ...
Fails with gcc 8 and -Wall on /root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/dist/include/mozilla/BlocksRingBuffer.h:333:26: error: '~' on an expression of ...
Read more >
Bug #1778626 “cannot convert 'bool' to 'boolean' in return”
I get rid of the error by either changing the return type from boolean to bool or changing uses of "return true;" to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found