Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitcoin API throws error 500 on bounties/<bountyId>/ endpoint #5307

Closed
Solexplorer opened this issue Oct 8, 2019 · 12 comments
Closed

Gitcoin API throws error 500 on bounties/<bountyId>/ endpoint #5307

Solexplorer opened this issue Oct 8, 2019 · 12 comments
Labels

Comments

@Solexplorer
Copy link
Contributor

Describe the bug

When trying to get data using a bounty id, it returns error 500:
immagine

To Reproduce

Use the gitcoin endpoint: https://gitcoin.co/api/v0.1/bounties/3538 where 3538 is the last bounty as of the time of writing, I have tried with other bounties but the result is still the same.

Expected behavior

I expect to get bounty details given a bountyId

Screenshots

Desktop (please complete the following information):

  • OS: Linux
  • Browser:
  • Browser Version:

Smartphone (please complete the following information):

  • Device:
  • OS:
  • Browser:
  • Version:

Additional context

@kuhnchris kuhnchris added the api label Oct 9, 2019
@owocki
Copy link
Contributor

owocki commented Oct 21, 2019

AssertionError: Cannot filter a query once a slice has been taken.
  File "django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "rest_framework/viewsets.py", line 116, in view
    return self.dispatch(request, *args, **kwargs)
  File "rest_framework/views.py", line 495, in dispatch
    response = self.handle_exception(exc)
  File "rest_framework/views.py", line 455, in handle_exception
    self.raise_uncaught_exception(exc)
  File "rest_framework/views.py", line 492, in dispatch
    response = handler(request, *args, **kwargs)
  File "rest_framework/mixins.py", line 56, in retrieve
    instance = self.get_object()
  File "rest_framework/generics.py", line 98, in get_object
    obj = get_object_or_404(queryset, **filter_kwargs)
  File "rest_framework/generics.py", line 21, in get_object_or_404
    return _get_object_or_404(queryset, *filter_args, **filter_kwargs)
  File "django/shortcuts.py", line 93, in get_object_or_404
    return queryset.get(*args, **kwargs)
  File "cacheops/query.py", line 354, in get
    return qs._no_monkey.get(qs, *args, **kwargs)
  File "django/db/models/query.py", line 399, in get
    clone = self.filter(*args, **kwargs)
  File "django/db/models/query.py", line 892, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "django/db/models/query.py", line 904, in _filter_or_exclude
    "Cannot filter a query once a slice has been taken."

i took a look this morning + couldnt figure how how to fix it without breaking the offset/limit functionality of the API..
might have to plumb the internals of DRF

is this API route advertised somewhere? its not one that the app uses to my knowledge

@Solexplorer
Copy link
Contributor Author

Hey Kevin,

I found it in the Gitcoin API documentation:
immagine

I was trying to get bounty info given an ID

@owocki
Copy link
Contributor

owocki commented Oct 21, 2019

got it; pls use this format https://gitcoin.co/api/v0.1/bounties/?pk=3538 in the meantime as a workaround

@Solexplorer
Copy link
Contributor Author

Solexplorer commented Nov 20, 2019

Hey @owocki,

I was looking at why my script wasn't working and I found out that the API is not returning the details of the bounty even with the workaround you gave me. If I call it like this: bounties/?pk=3538/ I get back the last 5 bounties instead of the bounty I specified.

What I expect:
Given an ID, give me back the bounty details for that ID

What I get:
The last 5 bounties that have been posted

@owocki
Copy link
Contributor

owocki commented Nov 20, 2019

got an example URL? looks like its working for me https://gitcoin.co/api/v0.1/bounties/?pk=3538

@Solexplorer
Copy link
Contributor Author

Maybe I didn't explain myself.
I am trying to fetch the details of a certain bounty given an ID. If you test this: https://gitcoin.co/api/v0.1/bounties/?pk=3589&network=mainnet, you are giving me back the last 5 bounties and not the bounty 3589

owocki added a commit that referenced this issue Nov 20, 2019
@owocki
Copy link
Contributor

owocki commented Nov 20, 2019

oh ur right; here this will help: cce953d

will go out in our next deploy..

@Solexplorer
Copy link
Contributor Author

Thank you!

@Solexplorer
Copy link
Contributor Author

It's not returning anything back after the deploy 😅 . I tested it like this: https://gitcoin.co/api/v0.1/bounties/?pk=3538

@owocki
Copy link
Contributor

owocki commented Nov 22, 2019

@Solexplorer 3538 is not a current bounty. try this instead http://gitcoin.co/api/v0.1/bounties/?pk=9781

@owocki
Copy link
Contributor

owocki commented Nov 22, 2019

we could change this by exempting the 'pk' key at https://github.com/gitcoinco/web/blob/master/app/dashboard/router.py#L235 if ppl feel strongly about that

@Solexplorer
Copy link
Contributor Author

Opsie my bad. Thanks for checking in

thelostone-mc added a commit that referenced this issue Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants